fix(sentry): handle REST issue event formatting#1342
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
nhopeatall
left a comment
There was a problem hiding this comment.
Summary
Requesting changes for one REST-shape gap: request query parameters from Sentry issue-event entries are still dropped.
Code Issues
Should Fix
- src/gadgets/sentry/core/format.ts:194 —
getEventRequest()returns the RESTrequestentry, butappendEventRequest()only readsquery_string/queryString. Sentry's Retrieve an Issue Event response puts request query params underdata.queryas tuple pairs, so a real REST event in that shape renders only the method and URL and loses the query values agents need. Please widenSentryRequestand formatqueryarrays/maps, with a regression test using that REST shape.
Verification
npx vitest run --project unit-core tests/unit/gadgets/sentry/format.test.ts tests/unit/gadgets/sentry/getSentryEventDetail.test.ts tests/unit/sentry/client.test.ts
🕵️ codex · gpt-5.5 · run details
| lines.push(`${event.request.method ?? 'GET'} ${event.request.url}`); | ||
| if (event.request.query_string) lines.push(`Query: ${event.request.query_string}`); | ||
| lines.push(`${request.method ?? 'GET'} ${request.url}`); | ||
| const query = request.query_string ?? request.queryString; |
There was a problem hiding this comment.
This still misses Sentry's REST request query shape. The issue-event API returns request entry data with query tuple pairs, not queryString; those parameters are currently omitted. Please normalize query here too.
There was a problem hiding this comment.
Fixed! Added a query field to SentryRequest typed as string | Array<[string, string]> | Record<string, string> to cover Sentry's REST issue-event shape. Extracted a normalizeRequestQuery() helper that:
- Tries
query_string/queryStringfirst (existing aliases) - Falls through to
query— serializing tuple pairs askey=value&..., records the same way, or passing a plain string as-is
appendEventRequest now calls this helper so tuple-pair query params from REST events are rendered in the Query: line. Four new regression tests cover: tuple-pairs, record shape, plain-string passthrough, and the precedence rule (query_string wins over query). All 28 targeted tests pass.
Widens SentryRequest with a `query` field (tuple pairs | record | string) to cover Sentry's Retrieve-an-Issue-Event REST shape where query params are returned under `data.query` rather than `queryString`. Adds normalizeRequestQuery() helper that falls back from query_string/queryString to the tuple-pairs/record/string shape, and regression tests for each variant plus the precedence rule. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
nhopeatall
left a comment
There was a problem hiding this comment.
LGTM - the formatter now handles the REST issue-event shapes from the work item, including object tags, entry-based exception/breadcrumb/request data, request query tuples/maps, frame aliases, and compact context output. Targeted unit verification passed locally:
RUN v3.2.4 /workspace/cascade-cascade-1778507589998
✓ |unit-core| tests/unit/gadgets/sentry/format.test.ts (7 tests) 3ms
✓ |unit-core| tests/unit/gadgets/sentry/getSentryEventDetail.test.ts (2 tests) 3ms
Test Files 2 passed (2)
Tests 9 passed (9)
Start at 13:56:51
Duration 304ms (transform 156ms, setup 34ms, collect 148ms, tests 7ms, environment 0ms, prepare 101ms) (28 tests).
🕵️ codex · gpt-5.5 · run details
Summary
Fixes https://linear.app/issue/MNG-665
This PR makes
GetAlertingEventDetailtolerant of Sentry's REST issue-event response shape so object-array tags and REST aliases no longer crash formatting before agents can see the alert details.Changes
id,eventID,dateCreated,entries, object-array tags, request entries, and frame aliases likelineNo,inApp,absPath, and sourcecontext.entries, REST stack frame aliases, and compact event context output.getSentryEventDetail()core path.Verification
npx vitest run --project unit-core tests/unit/gadgets/sentry/format.test.ts tests/unit/gadgets/sentry/getSentryEventDetail.test.ts tests/unit/sentry/client.test.tsnpm run lint:fixnpm run lint(passes; reports existing warning-level findings in unrelated files)npm run typechecknpm testnpm run buildnode bin/cascade-tools.js alerting get-alerting-event --organizationId mongrel --issueId 119054737 --eventId latestreturnedsuccess: trueand formatted stacktrace/tags/breadcrumbs/context.Notes
A bare
cascade-tools ...smoke before building this checkout used the installed PATH binary and reproduced the original iterable error. Afternpm run build,node bin/cascade-tools.js ...exercised this branch's localdist/and succeeded.🕵️ codex · gpt-5.5 · run details