( foundWorkflow: any, foundWebhook: any, requestId: string )
| 489 | * Run preprocessing checks for webhook execution |
| 490 | */ |
| 491 | export 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 | } |
no test coverage detected