From 621aa65b91007bebce2e72c541368348f02c954c Mon Sep 17 00:00:00 2001 From: Theodore Li Date: Wed, 8 Apr 2026 12:30:12 -0700 Subject: [PATCH] fix(webhook): throw webhook errors as 4xxs (#4050) * fix(webhook): throw webhook errors as 4xxs * Fix shadowing body var --------- Co-authored-by: Theodore Li --- apps/sim/lib/webhooks/processor.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/sim/lib/webhooks/processor.ts b/apps/sim/lib/webhooks/processor.ts index d75f539ee3..ba20a6c4cb 100644 --- a/apps/sim/lib/webhooks/processor.ts +++ b/apps/sim/lib/webhooks/processor.ts @@ -725,7 +725,15 @@ export async function processPolledWebhookEvent( try { const preprocessResult = await checkWebhookPreprocessing(foundWorkflow, foundWebhook, requestId) if (preprocessResult.error) { - return { success: false, error: 'Preprocessing failed', statusCode: 500 } + const errorResponse = preprocessResult.error + const statusCode = errorResponse.status + const errorBody = await errorResponse.json().catch(() => ({})) + const errorMessage = errorBody.error ?? 'Preprocessing failed' + logger.warn(`[${requestId}] Polled webhook preprocessing failed`, { + statusCode, + error: errorMessage, + }) + return { success: false, error: errorMessage, statusCode } } if (foundWebhook.blockId) {