fix(webhook): throw webhook errors as 4xxs#4050
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryLow Risk Overview
Reviewed by Cursor Bugbot for commit c82de96. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummaryThis PR fixes Confidence Score: 4/5Safe to merge — the fix correctly propagates preprocessing status codes, the change is minimal and well-scoped, and the catch block still guards against unexpected exceptions. The logic change is straightforward and correct. The only minor concern is a non-null assertion on an optional TypeScript field that is safe today but could be fragile if the apps/sim/lib/webhooks/processor.ts line 453 — non-null assertion on optional
|
| Filename | Overview |
|---|---|
| apps/sim/lib/webhooks/processor.ts | Fixes checkWebhookPreprocessing to propagate the actual error.statusCode from preprocessExecution instead of hardcoding 500, correctly surfacing 4xx errors for user-caused failures (deleted workflows, rate limits, etc.); uses a non-null assertion on an optional field. |
Sequence Diagram
sequenceDiagram
participant WH as Webhook Route
participant CP as checkWebhookPreprocessing
participant PE as preprocessExecution
participant FPE as formatProviderErrorResponse
WH->>CP: checkWebhookPreprocessing(workflow, webhook, requestId)
CP->>PE: preprocessExecution({workflowId, userId, ...})
alt success === false (user error: deleted, rate-limit, etc.)
PE-->>CP: {success: false, error: {message, statusCode: 4xx|5xx}}
CP->>FPE: formatProviderErrorResponse(webhook, error.message, error.statusCode)
FPE-->>CP: NextResponse (correct 4xx or 5xx)
CP-->>WH: {error: NextResponse}
else success === true
PE-->>CP: {success: true, actorUserId, ...}
CP-->>WH: {error: null, actorUserId, executionId, correlation}
else unexpected exception thrown
PE-->>CP: throws
CP->>FPE: formatProviderErrorResponse(webhook, 'Internal error during preprocessing', 500)
FPE-->>CP: NextResponse (500)
CP-->>WH: {error: NextResponse (500)}
end
Comments Outside Diff (1)
-
apps/sim/lib/webhooks/processor.ts, line 453 (link)Non-null assertion on optional field
preprocessResult.error!silences TypeScript's complaint, but thePreprocessExecutionResultinterface declareserroras optional (error?). While the current implementation ofpreprocessExecutionalways supplies anerrorobject whensuccess === false, any future path that returns{success: false}withouterrorwill throw at runtime. A defensive fallback is safer.
Reviews (1): Last reviewed commit: "fix(webhook): throw webhook errors as 4x..." | Re-trigger Greptile
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ce3859d. Configure here.
* fix(webhook): throw webhook errors as 4xxs * Fix shadowing body var --------- Co-authored-by: Theodore Li <theo@sim.ai>
* fix(billing): skip billing on streamed workflows with byok * Simplify logic * Address comments, skip tokenization billing fallback * Fix tool usage billing for streamed outputs * 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> * feat(enterprise): cloud whitelabeling for enterprise orgs (#4047) * feat(enterprise): cloud whitelabeling for enterprise orgs * fix(enterprise): scope enterprise plan check to target org in whitelabel PUT * fix(enterprise): use isOrganizationOnEnterprisePlan for org-scoped enterprise check * fix(enterprise): allow clearing whitelabel fields and guard against empty update result * fix(enterprise): remove webp from logo accept attribute to match upload hook validation * improvement(billing): use isBillingEnabled instead of isProd for plan gate bypasses * fix(enterprise): show whitelabeling nav item when billing is enabled on non-hosted environments * fix(enterprise): accept relative paths for logoUrl since upload API returns /api/files/serve/ paths * fix(whitelabeling): prevent logo flash on refresh by hiding logo while branding loads * fix(whitelabeling): wire hover color through CSS token on tertiary buttons * fix(whitelabeling): show sim logo by default, only replace when org logo loads * fix(whitelabeling): cache org logo url in localstorage to eliminate flash on repeat visits * feat(whitelabeling): add wordmark support with drag/drop upload * updated turbo * fix(whitelabeling): defer localstorage read to effect to prevent hydration mismatch * fix(whitelabeling): use layout effect for cache read to eliminate logo flash before paint * fix(whitelabeling): cache theme css to eliminate color flash before org settings resolve * fix(whitelabeling): deduplicate HEX_COLOR_REGEX into lib/branding and remove mutation from useCallback deps * fix(whitelabeling): use cookie-based SSR cache to eliminate brand flash on all page loads * fix(whitelabeling): use !orgSettings condition to fix SSR brand cache injection React Query returns isLoading: false with data: undefined during SSR, so the previous brandingLoading condition was always false on the server — initialCache was never injected into brandConfig. Changing to !orgSettings correctly applies the cookie cache both during SSR and while the client-side query loads, eliminating the logo flash on hard refresh. * fix(editor): stop highlighting start.input as blue when block is not connected to starter (#4054) * fix: merge subblock values in auto-layout to prevent losing router context (#4055) Auto-layout was reading from getWorkflowState() without merging subblock store values, then persisting stale subblock data to the database. This caused runtime-edited values (e.g. router_v2 context) to be overwritten with their initial/empty values whenever auto-layout was triggered. * fix(whitelabeling): eliminate logo flash by fetching org settings server-side (#4057) * fix(whitelabeling): eliminate logo flash by fetching org settings server-side * improvement(whitelabeling): add SVG support for logo and wordmark uploads * skelly in workspace header * remove dead code * fix(whitelabeling): hydration error, SVG support, skeleton shimmer, dead code removal * fix(whitelabeling): blob preview dep cycle and missing color fallback * fix(whitelabeling): use brand-accent as color fallback when workspace color is undefined * chore(whitelabeling): inline hasOrgBrand --------- Co-authored-by: Theodore Li <theo@sim.ai>

Summary
We recently cought all preprocessResult errors as 5xxs. These can be caused by workflows deleted, usage limit exceeded, rate limit exceeded, etc which are all user errors. Changed this to correctly throw using status and error passed from
preprocessResultType of Change
Testing
Checklist
Screenshots/Videos