Skip to content

fix(sentry): match event_alert payloads that carry a numeric project id - #1584

Merged
zbigniewsobiecki merged 1 commit into
mongrel-intelligence:devfrom
dgertych-monterail:fix/sentry-event-alert-project-filter
Nov 23, 2026
Merged

zbigniewsobiecki merged 1 commit into
mongrel-intelligence:devfrom
dgertych-monterail:fix/sentry-event-alert-project-filter

Conversation

@dgertych-monterail

Copy link
Copy Markdown
Contributor

Summary

Sentry's event_alert webhook sends data.event.project as a bare number (the project id). The
project filter only understood a string or an object, so it dropped the number, found no project
and skipped every alert with missing_payload_project. The webhook was acknowledged with 200 but
no agent ever ran, whatever projectSlug was configured.

  • Read a numeric event.project as a project id.
  • Take the project slug from data.event.url (.../projects/<org>/<slug>/events/<id>/), which is
    what the Sentry integration is configured with, so existing configs keep working.
  • Alerts from another project are still rejected.

Real log line from a Sentry "Send Test Notification" before the fix:
Trigger sentry-project-filter skipped: missing_payload_project: configuredProjectSlug=cooleaf; payloadProjects=(missing)

Test Plan

  • Unit tests pass: tests/unit/sentry, tests/unit/router/adapters/sentry.test.ts and tests/unit/triggers (full suite not run)
  • Linter passes (npm run lint on the touched files)
  • Type check passes (npm run typecheck, clean install)
  • Tested manually: the compiled filter was run against the logged payload shape and now matches; not yet verified end to end on a deployed router

New cases: numeric id with matching and non-matching event.url, numeric id equal to the configured value, event.url without a slug.

Checklist

  • My code follows the project's code style
  • I have added tests for new functionality
  • I have updated documentation if needed
  • My commits follow Conventional Commits

Sentry sends data.event.project as a bare number in event_alert webhooks, which the project
filter dropped. Every alert was skipped with missing_payload_project and no agent ever ran.

Read the numeric id as a project id and take the slug from data.event.url, which is what the
integration is configured with.
@codecov

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@nhopeatall nhopeatall left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Summary

APPROVE — a correct, well-scoped fix for numeric event_alert project ids. The numeric-id branch and the data.event.url slug fallback are sound, matching still rejects other projects, and the new unit tests pass locally.

Verification (non-blocking confidence notes):

  • Widening project?: string | number | {…} in SentryEvent is safe — no other consumer dereferences SentryEvent.project. The only .project.name/.slug read is on SentryIssue.project in src/gadgets/sentry/core/format.ts:39, a different type. So number can't break formatting/trigger code.
  • The change is strictly non-regressive: numeric payloads were previously dropped as missing_payload_project; now they match by slug (from event.url) or by numeric id, and a payload whose url has no slug still skips (as a mismatch), so no alert from another project can slip through. The "rejects … from another project" test confirms this.
  • The payload flows unchanged through SentryRouterAdapter → matchSentryPayloadProject, so data.event.url is preserved end to end.

Code Issues

Should Fix (minor / test organization)

  • tests/unit/sentry/project-filter.test.ts:249 — the three new matchSentryPayloadProject event_alert tests live inside the describe.each([event_alert, metric_alert, issue]) block but hardcode makeEventAlertPayload, ignoring the parametrized makePayload. They therefore execute 3× each (6 redundant runs) and appear misleadingly under the metric_alert and issue describe groups. Moving them to a dedicated event_alert describe (as you did for the two new top-level extractSentryPayloadProjects cases) keeps the grouping honest.

Questions

  • The slug path assumes event.url is the API form .../projects/<org>/<slug>/events/<id>/. The PR says end-to-end isn't verified on a deployed router yet — can you confirm production event.url carries that shape rather than the web_url /issues/<id>/events/<id>/ form? If only web_url is present, the slug fallback won't fire and matching reduces to the numeric id equalling the configured value. Still non-regressive, just worth confirming so slug-configured projects actually start matching.

🕵️ claude-code · claude-opus-4-8 · run details

expect(result.payloadProjects.length).toBeGreaterThan(0);
});

it('allows an event_alert with a numeric project id when the event.url slug matches', () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

These three event_alert tests are nested in the describe.each([event_alert, metric_alert, issue]) block but hardcode makeEventAlertPayload instead of the parametrized makePayload, so they run 3× each (6 redundant executions) and show up under the metric_alert/issue describe groups. Consider moving them into a dedicated event_alert describe block, mirroring the two new top-level extractSentryPayloadProjects cases. Not blocking — behavior is correct and all 32 tests pass.

@zbigniewsobiecki
zbigniewsobiecki merged commit 082897b into mongrel-intelligence:dev Nov 23, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants