fix(webhooks): resolve env var references before deploy-triggered subscription creation#5619
Conversation
…scription creation
Provider config fields like an API key can reference an environment
variable via {{VAR_NAME}}. The interactive trigger-save route already
resolved these before calling a provider's createSubscription, but the
async deployment-outbox path (workflow deploy -> saveTriggerWebhooksForDeploy
-> createExternalWebhookSubscription) did not, so the literal unresolved
{{VAR_NAME}} string was sent to the provider as the credential and
rejected. Resolve env vars in createExternalWebhookSubscription itself so
both callers behave the same; the persisted providerConfig keeps storing
the unresolved template, only the outbound call gets the resolved value.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Returned Adds Reviewed by Cursor Bugbot for commit 69bcb97. Configure here. |
Greptile SummaryThis PR fixes env-var-backed webhook provider config during external subscription creation. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (2): Last reviewed commit: "fix(webhooks): guard against a non-strin..." | Re-trigger Greptile |
…env vars
workflow.workspaceId as string | undefined was an unchecked cast on a
Record<string, unknown> — if a caller ever passed a workflow-like object
where workspaceId isn't actually a string, workspace-scoped {{VAR}}
references would silently stay unresolved and the provider would receive
the literal template as the credential, reproducing the exact class of bug
this change exists to fix. Replaced with a runtime typeof check that falls
back to undefined (personal-env-only resolution) instead of forwarding an
unvalidated value.
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 69bcb97. Configure here.
Summary
{{VAR_NAME}}. The interactive trigger-save route (app/api/webhooks/route.ts) already resolved these before calling a provider'screateSubscription, but the async deployment-outbox path (workflow deploy ->saveTriggerWebhooksForDeploy->createExternalWebhookSubscription) did not.{{VAR_NAME}}string to the provider as the credential, which the provider correctly rejects (e.g. Ashby returns 401 "Invalid API Key").createExternalWebhookSubscriptionitself, so both callers get consistent behavior. The persistedproviderConfigstill stores the unresolved template — only the outbound provider call gets the resolved value.createSubscription(auto webhook-lifecycle registration). Providers without it (e.g. Slack) never touch this path — their env var resolution already happens correctly in the separate inbound-request verification path (processor.ts).Type of Change
Testing
apps/sim/lib/webhooks/provider-subscriptions.test.ts: env vars resolve before the provider call, persisted config stays unresolved, providers withoutcreateSubscriptionskip resolution entirely.bunx turbo run type-check --filter=sim --forceclean (confirmed one unrelated pre-existing failure inproviders/meta/index.tsexists identically on unmodifiedstaging, unaffected by this change).bun run check:api-validationpasses.Checklist