Skip to content
Merged
Prev Previous commit
Next Next commit
fix(webhook): throw webhook errors as 4xxs (#4050)
* fix(webhook): throw webhook errors as 4xxs

* Fix shadowing body var

---------

Co-authored-by: Theodore Li <theo@sim.ai>
  • Loading branch information
TheodoreSpeaks and TheodoreSpeaks committed Apr 8, 2026
commit edfdc16236d089dbbc4b71c96f329c11269d2be2
10 changes: 9 additions & 1 deletion apps/sim/lib/webhooks/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down