Skip to content

fix(gitlab): re-push webhook tokens on integration (re)install#117801

Merged
billyvg merged 1 commit into
masterfrom
jacquev6/refresh-gitlab-webhooks-on-reinstall
Jun 22, 2026
Merged

fix(gitlab): re-push webhook tokens on integration (re)install#117801
billyvg merged 1 commit into
masterfrom
jacquev6/refresh-gitlab-webhooks-on-reinstall

Conversation

@jacquev6

Copy link
Copy Markdown
Collaborator

This PR addresses the point "0." in this comment.

It was authored by Claude and reviewed by me. I'm confident enough to submit it.

Todo:

  • Test end-to-end in dev.

The GitLab webhook_secret is derived deterministically from the OAuth app's client_id (sha1(hostname + client_id)) and stored on the shared Integration.metadata. When a customer reinstalls against a new OAuth app the client_id changes, so the secret rotates and metadata is overwritten, but the tokens already registered on existing GitLab project hooks are never re-pushed. Inbound webhooks then keep sending the old token and fail the constant-time secret check in webhooks.py with a 409.

Override post_install in GitlabIntegrationProvider to schedule a webhook refresh via the existing repository_service.schedule_update_gitlab_project_webhooks machinery. Because the secret lives on the shared Integration, refresh every organization that has the integration installed, not just the one running the (re)install. Fresh installs have no repos yet, so they are a harmless no-op.

The GitLab webhook_secret is derived deterministically from the OAuth
app's client_id (sha1(hostname + client_id)) and stored on the shared
Integration.metadata. When a customer reinstalls against a new OAuth app
the client_id changes, so the secret rotates and metadata is overwritten,
but the tokens already registered on existing GitLab project hooks are
never re-pushed. Inbound webhooks then keep sending the old token and
fail the constant-time secret check in webhooks.py with a 409.

Override post_install in GitlabIntegrationProvider to schedule a webhook
refresh via the existing repository_service.schedule_update_gitlab_project_webhooks
machinery. Because the secret lives on the shared Integration, refresh
every organization that has the integration installed, not just the one
running the (re)install. Fresh installs have no repos yet, so they are a
harmless no-op.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 16, 2026
@billyvg

billyvg commented Jun 17, 2026

Copy link
Copy Markdown
Member

@GabeVillalobos do you have any context on this? would you be able to review it?

@GabeVillalobos

Copy link
Copy Markdown
Member

@billyvg Yep, this change makes sense. Seems like we just missed the update case somehow, so I wonder how long this has actually been broken.

@GabeVillalobos GabeVillalobos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good

@billyvg billyvg marked this pull request as ready for review June 18, 2026 17:08
@billyvg billyvg requested a review from a team as a code owner June 18, 2026 17:08
@billyvg

billyvg commented Jun 18, 2026

Copy link
Copy Markdown
Member

SFO is out tomorrow, gonna wait until Monday to merge

@billyvg billyvg merged commit 5f936e6 into master Jun 22, 2026
65 checks passed
@billyvg billyvg deleted the jacquev6/refresh-gitlab-webhooks-on-reinstall branch June 22, 2026 16:19
@GabeVillalobos GabeVillalobos added the Trigger: Revert Add to a merged PR to revert it (skips CI) label Jun 23, 2026
@getsentry-bot

Copy link
Copy Markdown
Contributor

PR reverted: 1f832b5

getsentry-bot added a commit that referenced this pull request Jun 23, 2026
#117801)"

This reverts commit 5f936e6.

Co-authored-by: GabeVillalobos <5643012+GabeVillalobos@users.noreply.github.com>
@GabeVillalobos

Copy link
Copy Markdown
Member

This looks like it conflicts with #112699, so I'm reverting in the meantime. We need to unify our webhook update and creation logic before reattempting it I think.

sehr-m pushed a commit that referenced this pull request Jun 23, 2026
This PR addresses the point "0." in [this
comment](#93724 (comment)).

It was authored by Claude and reviewed by me. I'm confident enough to
submit it.

Todo:
- [ ] Test end-to-end in dev.

The GitLab webhook_secret is derived deterministically from the OAuth
app's client_id (sha1(hostname + client_id)) and stored on the shared
Integration.metadata. When a customer reinstalls against a new OAuth app
the client_id changes, so the secret rotates and metadata is
overwritten, but the tokens already registered on existing GitLab
project hooks are never re-pushed. Inbound webhooks then keep sending
the old token and fail the constant-time secret check in webhooks.py
with a 409.

Override post_install in GitlabIntegrationProvider to schedule a webhook
refresh via the existing
repository_service.schedule_update_gitlab_project_webhooks machinery.
Because the secret lives on the shared Integration, refresh every
organization that has the integration installed, not just the one
running the (re)install. Fresh installs have no repos yet, so they are a
harmless no-op.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
sehr-m pushed a commit that referenced this pull request Jun 23, 2026
#117801)"

This reverts commit 5f936e6.

Co-authored-by: GabeVillalobos <5643012+GabeVillalobos@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components Trigger: Revert Add to a merged PR to revert it (skips CI)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants