Skip to content

fix(integrations): Record GitLab webhook Http404 as halt, not error#120320

Open
sentry[bot] wants to merge 2 commits into
masterfrom
seer/fix-integration-webhook-http404
Open

fix(integrations): Record GitLab webhook Http404 as halt, not error#120320
sentry[bot] wants to merge 2 commits into
masterfrom
seer/fix-integration-webhook-http404

Conversation

@sentry

@sentry sentry Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor
GitLab webhooks, particularly when an unrecognized project ID or missing author email is encountered, intentionally raise `django.http.Http404`. Previously, the `IntegrationEventLifecycle` wrapper treated these expected 404s as unhandled exceptions, leading to a high volume of spurious Sentry error issues.

An initial attempt to fix this involved adding a blanket Http404 exemption to IntegrationEventLifecycle.__exit__. However, this was identified as problematic, as other integration flows (e.g., identity linking) also re-raise IntegrityError as Http404, and silencing these would mask genuine application errors.

This revised fix addresses the issue by:

  1. Reverting the generic Http404 handling from IntegrationEventLifecycle.__exit__ in src/sentry/integrations/utils/metrics.py.
  2. Implementing a targeted try/except Http404 block around the event_handler call within the GitLab webhook dispatch loop in src/sentry/integrations/gitlab/webhooks.py. When an Http404 is caught in this specific context, lifecycle.record_halt(e) is explicitly called before re-raising the exception.

This ensures that expected Http404s originating specifically from GitLab webhooks are correctly recorded as halt events (preventing Sentry error issues), while maintaining proper error reporting for Http404s that might indicate genuine problems in other integration contexts.

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

Fixes SENTRY-43KZ

Comment @sentry <feedback> on this PR to have Autofix iterate on the changes.

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jul 22, 2026
Comment thread src/sentry/integrations/utils/metrics.py Outdated
@sentry sentry Bot changed the title fix(integrations): Prevent Http404 from creating Sentry issues in webhook lifecycle fix(integrations): Record GitLab webhook Http404 as halt, not error Jul 22, 2026
@sentry
sentry Bot requested a review from a team as a code owner July 22, 2026 13:26
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant