Repository navigation
fix(sentry): match event_alert payloads that carry a numeric project id - #1584
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
nhopeatall
left a comment
There was a problem hiding this comment.
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 | {…}inSentryEventis safe — no other consumer dereferencesSentryEvent.project. The only.project.name/.slugread is onSentryIssue.projectinsrc/gadgets/sentry/core/format.ts:39, a different type. Sonumbercan'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 (fromevent.url) or by numeric id, and a payload whoseurlhas 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, sodata.event.urlis preserved end to end.
Code Issues
Should Fix (minor / test organization)
- tests/unit/sentry/project-filter.test.ts:249 — the three new
matchSentryPayloadProjectevent_alert tests live inside thedescribe.each([event_alert, metric_alert, issue])block but hardcodemakeEventAlertPayload, ignoring the parametrizedmakePayload. They therefore execute 3× each (6 redundant runs) and appear misleadingly under themetric_alertandissuedescribe groups. Moving them to a dedicated event_alertdescribe(as you did for the two new top-levelextractSentryPayloadProjectscases) keeps the grouping honest.
Questions
- The slug path assumes
event.urlis 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 productionevent.urlcarries that shape rather than theweb_url/issues/<id>/events/<id>/form? If onlyweb_urlis 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', () => { |
There was a problem hiding this comment.
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.
Summary
Sentry's
event_alertwebhook sendsdata.event.projectas a bare number (the project id). Theproject 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 butno agent ever ran, whatever
projectSlugwas configured.event.projectas a project id.data.event.url(.../projects/<org>/<slug>/events/<id>/), which iswhat the Sentry integration is configured with, so existing configs keep working.
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
tests/unit/sentry,tests/unit/router/adapters/sentry.test.tsandtests/unit/triggers(full suite not run)npm run linton the touched files)npm run typecheck, clean install)New cases: numeric id with matching and non-matching
event.url, numeric id equal to the configured value,event.urlwithout a slug.Checklist