From ce3859dfc8e5ecbfb4c257627563c03cf99fdf65 Mon Sep 17 00:00:00 2001 From: Theodore Li Date: Wed, 8 Apr 2026 11:10:53 -0700 Subject: [PATCH 1/2] fix(webhook): throw webhook errors as 4xxs --- 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..9fee9f0745 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 body = await errorResponse.json().catch(() => ({})) + const errorMessage = body.error ?? 'Preprocessing failed' + logger.warn(`[${requestId}] Polled webhook preprocessing failed`, { + statusCode, + error: errorMessage, + }) + return { success: false, error: errorMessage, statusCode } } if (foundWebhook.blockId) { From c82de969c8aaf9444b928f713f6a14cedec27d14 Mon Sep 17 00:00:00 2001 From: Theodore Li Date: Wed, 8 Apr 2026 12:10:16 -0700 Subject: [PATCH 2/2] Fix shadowing body var --- apps/sim/lib/webhooks/processor.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/sim/lib/webhooks/processor.ts b/apps/sim/lib/webhooks/processor.ts index 9fee9f0745..ba20a6c4cb 100644 --- a/apps/sim/lib/webhooks/processor.ts +++ b/apps/sim/lib/webhooks/processor.ts @@ -727,8 +727,8 @@ export async function processPolledWebhookEvent( if (preprocessResult.error) { const errorResponse = preprocessResult.error const statusCode = errorResponse.status - const body = await errorResponse.json().catch(() => ({})) - const errorMessage = body.error ?? 'Preprocessing failed' + const errorBody = await errorResponse.json().catch(() => ({})) + const errorMessage = errorBody.error ?? 'Preprocessing failed' logger.warn(`[${requestId}] Polled webhook preprocessing failed`, { statusCode, error: errorMessage,