Repository navigation
fix(webhooks): accept the methods and expose the request metadata the generic webhook advertises - #6893
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #6889, whose four commits this branch contains unchanged and unsquashed — the feature is @minijeong-log's work and their authorship is preserved in git history. Please credit that PR when merging.
Fixes #6888.
The bug
Open a Webhook Trigger today and the Setup Instructions make three claims. All three are false:
405.formatInputisreturn { input: body }— headers and query parameters are read off the request and discarded.Authorization: Bearer"verifyTokenAuthreturns early; Bearer never works.So a service calling
.../trigger/abc?orderId=123withX-Event-Name: createdreaches a workflow that can see neither value, and no way exists to get them. You referencequery.orderIdbecause the panel said the data was there, get nothing, and have no indication why.What this does
Makes the panel true, as an opt-in.
queryis exposed unconditionally — it is dropped today, it only appears when the caller's own URL carries parameters, and a body field of the same name still wins. That is the reported bug and it needs no toggle.Everything else is a per-webhook flag, off by default:
providerConfigflagacceptOtherMethodsmethodexposeRequestHeadersheaders, minus credential-bearing onesextraDeliveryMethodsdeclares the methods and the flag that unlocks them, soacceptsWebhookDeliveryMethodrequires both. A provider-level capability alone would have changed behavior for every generic webhook already deployed — accepting GET on URLs that answered405yesterday, and writing every inbound header into execution logs on POST deliveries that never asked for it.methodrides the methods flag rather than getting its own: until a webhook accepts more than POST it is the constant"POST", so emitting it would change every existing payload to say nothing.Trigger outputs are
condition-gated on their switches, so the reference dropdown cannot offer a field the running webhook will not send.Two cross-provider bugs fixed along the way
Challenge handlers run before the webhook lookup and match on payload shape alone, so one that answers on a method its provider never uses will intercept a delivery addressed to whoever owns the path. Today a
GET ?validationToken=abcto any webhook path echoesabcback with a 200.handleProviderChallengesnow gates every handler toPOSTby default viachallengeMethods. WhatsApp widens it toGET— Meta sends the verification handshake that way — so the one real exception is stated in the type rather than implied by the absence of a guard.Separately, WhatsApp answered
403forhub.*parameters on a path with no WhatsApp webhook expecting a token. Those parameters belong to whoever owns the path; it now falls through.Security
The credential-header denylist covers 24 names (
authorization,apikey,x-functions-key,x-access-token,x-amz-security-token,x-goog-api-key, …). Because a denylist is leaky by construction it is not the only defense: the webhook's own token is withheld by value as well as by name, catching a sender that repeats it under a header nobody anticipated. Value matching applies only above 8 characters so a short token cannot strip unrelated headers. And the whole feature is off unless the owner turns it on.Note that authentication is header-based, so it cannot be used with a plain link — the "trigger from a URL in an email" case requires disabling auth. The instructions now say so outright instead of leaving users to discover it after publishing an open trigger URL.
Compatibility
No migration. The gate is the absence of a database key: every generic webhook written before this exists has neither flag,
undefinedreads as off, and the old behavior is what the new code produces when it finds nothing.acceptsWebhookDeliveryMethodreturns true for POST before reading anything).query.methodandheadersare absent without flags.405; without the flag they return405.staging— unknown path, un-flagged generic webhook, POST-only provider, non-path trigger and pending setup verification all answer exactly as they do today.payload.query/methodare optional and defaulted on read, and the payload has no runtime schema, so a new payload on an old worker during a rolling deploy is inert.Three things do change, all intentional, two of them the bug fixes:
queryappears when the caller's URL has parameters.GET ?validationToken=abcstops echoing (Graph sends validation as POST; unaffected).hub.*on a path with no WhatsApp webhook returns405instead of403.Also
webhookTriggerPostContract, whosemethod: 'POST'had become untrue.405withAllow: POST, whether the path is unknown, holds only non-path triggers, or holds a trigger that has not opted in — so a probe cannot tell them apart.Object.hasOwnreplaceskey in body, so an inherited property name no longer reads as a collision and swallows the metadata.isProviderConfigFlagEnabled, which treats onlytrue/'true'as on: the editor writes booleans, but a YAML- or Copilot-authored workflow can write the string'false', which is truthy and would ship the inverse of the setting the user sees.debug, notwarn— each fires once per delivery for a webhook whose shape simply is that way.Testing
vitest run lib/webhooks triggers app/api/webhooks→ 823 passed / 66 files. Fullapps/simsuite → 28,616 passed, one unrelated pre-existing flake (lib/auth/sso-trust.test.ts, a 10s import timeout that fails at a similar rate onstaging— 1 in 4 there, 1 in 3 here).bun run type-checkclean,bun run check:audits32/32, realnext buildcompletes.Every guard was mutation-tested — reverted individually, confirmed red, restored:
Boolean(value)flag coercionThat last row exists because an earlier revision of this branch did invert it, and it passed all 820 tests at the time — nothing asserted where the challenge offer sat relative to the load-shed gate or the verification probe. Cursor Bugbot caught the half I had missed: behind
tryAdmit, a busy instance answers429to Meta's WhatsApp handshake and the webhook silently fails to verify at setup time.Not verified: nobody has sent a real HTTP request at a running instance on this branch. Worth a manual pass before this reaches production.