- Notifications
You must be signed in to change notification settings - Fork55k
fix(nodes): Prevent duplicate webhooks on GitLab/GitHub trigger publish#25996
fix(nodes): Prevent duplicate webhooks on GitLab/GitHub trigger publish#25996nielskaspers wants to merge 1 commit inton8n-io:masterfrom
Conversation
When a workflow with a GitLab or GitHub trigger is published, thecheckExists() method only verifies the stored webhook ID. If that IDbecomes stale (e.g. after workflow import, node copy, or databasereset), the lookup returns 404 and a new duplicate webhook is created.This adds a URL-based fallback: when the stored ID fails, list allwebhooks for the repository and match by the n8n webhook URL. Thisprevents duplicate webhook creation while preserving the fast-pathID lookup for the common case.Fixesn8n-io#25381
Hey@nielskaspers, Thank you for your contribution. We appreciate the time and effort you’ve taken to submit this pull request. Before we can proceed, please ensure the following: Regarding new nodes: If your node integrates with an AI service that you own or represent, please emailnodes@n8n.io and we will be happy to discuss the best approach. About review timelines: Thank you again for contributing to n8n. |
Summary
checkExists()in bothGitlabTrigger.node.tsandGithubTrigger.node.tsto fall back to URL-based webhook matching when the stored webhook ID becomes staleGithubTrigger.node.test.tsThe problem
When publishing a workflow,
checkExists()only checks if the storedwebhookData.webhookIdexists on the platform. If that ID becomes stale (after workflow import, node copy, or database reset), the check returnsfalseandcreate()adds a new webhook — creating a duplicate on every publish.The fix
Both trigger nodes now follow this strategy in
checkExists():This is the same pattern GitHub's
create()method already uses in its 422 error handler — moved tocheckExists()where it prevents the problem instead of recovering from it.Fixes#25381
Test plan
checkExiststest to includegetNodeWebhookUrlmock