MCPcopy Index your code
hub / github.com/simstudioai/sim / checkWebhookPreprocessing

Function checkWebhookPreprocessing

apps/sim/lib/webhooks/processor.ts:491–548  ·  view source on GitHub ↗
(
  foundWorkflow: any,
  foundWebhook: any,
  requestId: string
)

Source from the content-addressed store, hash-verified

489 * Run preprocessing checks for webhook execution
490 */
491export async function checkWebhookPreprocessing(
492 foundWorkflow: any,
493 foundWebhook: any,
494 requestId: string
495): Promise<WebhookPreprocessingResult> {
496 try {
497 const executionId = generateId()
498 const correlation = {
499 executionId,
500 requestId,
501 source: 'webhook' as const,
502 workflowId: foundWorkflow.id,
503 webhookId: foundWebhook.id,
504 path: foundWebhook.path,
505 provider: foundWebhook.provider,
506 triggerType: 'webhook',
507 }
508
509 const preprocessResult = await preprocessExecution({
510 workflowId: foundWorkflow.id,
511 userId: foundWorkflow.userId,
512 triggerType: 'webhook',
513 executionId,
514 requestId,
515 triggerData: { correlation },
516 checkRateLimit: true,
517 checkDeployment: true,
518 workspaceId: foundWorkflow.workspaceId,
519 workflowRecord: foundWorkflow,
520 })
521
522 if (!preprocessResult.success) {
523 const error = preprocessResult.error!
524 logger.warn(`[${requestId}] Webhook preprocessing failed`, {
525 provider: foundWebhook.provider,
526 error: error.message,
527 statusCode: error.statusCode,
528 })
529
530 return {
531 error: formatProviderErrorResponse(foundWebhook, error.message, error.statusCode),
532 }
533 }
534
535 return {
536 error: null,
537 actorUserId: preprocessResult.actorUserId,
538 executionId,
539 correlation,
540 }
541 } catch (preprocessError) {
542 logger.error(`[${requestId}] Error during webhook preprocessing:`, preprocessError)
543
544 return {
545 error: formatProviderErrorResponse(foundWebhook, 'Internal error during preprocessing', 500),
546 }
547 }
548}

Callers 3

processor.test.tsFile · 0.90
handleWebhookPostFunction · 0.90

Calls 5

generateIdFunction · 0.90
preprocessExecutionFunction · 0.90
errorMethod · 0.80
warnMethod · 0.65

Tested by

no test coverage detected