{"record":{"id":"00cd4e6dbea8f928","repo":"oven-sh/bun","slug":"failed-to-fetch-sentry-event-response-statustex","errorCode":null,"errorMessage":"Failed to fetch Sentry event: ${response.statusText}","messagePattern":"Failed to fetch Sentry event: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/associate-issue-with-sentry.ts","lineNumber":24,"sourceCode":"}\n\nconst id = body.indexOf(\"<!-- sentry_id: \");\nconst endIdLine = body.indexOf(\" -->\", id + 1);\nif (!(id > -1 && endIdLine > -1)) {\n  throw new Error(\"Missing sentry_id\");\n}\nconst sentryId = body.slice(id + \"<!-- sentry_id: \".length, endIdLine).trim();\nif (!sentryId) {\n  throw new Error(\"Missing sentry_id\");\n}\n\nconst response = await fetch(`https://sentry.io/api/0/organizations/4507155222364160/eventids/${sentryId}/`, {\n  headers: {\n    Authorization: `Bearer ${SENTRY_AUTH_TOKEN}`,\n  },\n});\nif (!response.ok) {\n  throw new Error(`Failed to fetch Sentry event: ${response.statusText}`);\n}\nconst json = await response.json();\nconst groupId = json?.groupId;\nif (!groupId) {\n  throw new Error(\"Missing groupId\");\n}\n\nconst issueResponse = await fetch(`https://sentry.io/api/0/issues/${groupId}/`, {\n  headers: {\n    Authorization: `Bearer ${SENTRY_AUTH_TOKEN}`,\n  },\n});\nif (!issueResponse.ok) {\n  throw new Error(`Failed to fetch Sentry issue: ${issueResponse.statusText}`);\n}\nconst { shortId, permalink } = await issueResponse.json();\nif (!shortId || !permalink) {\n  throw new Error(\"Missing shortId or permalink\");","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/scripts/associate-issue-with-sentry.ts#L6-L42","documentation":"The Sentry event lookup GET /api/0/organizations/4507155222364160/eventids/<sentryId>/ returned a non-2xx status; only response.statusText is surfaced. Typical statuses: 401/403 for an invalid or scoped-out SENTRY_AUTH_TOKEN, 404 when the event id does not exist in org 4507155222364160, or the event fell outside Sentry's retention window.","triggerScenarios":"Token expired or revoked; token lacks org:read for organization 4507155222364160; sentryId extracted from the issue belongs to another Sentry org or is malformed; event purged by retention.","commonSituations":"Rotated Sentry auth token not updated in GitHub secrets; issue marker edited with a wrong id; old issues reprocessed after retention expiry.","solutions":["Verify the token: curl -H 'Authorization: Bearer $SENTRY_AUTH_TOKEN' the same URL and inspect the real status/body","Confirm the token has read scope on organization 4507155222364160 and update the SENTRY_AUTH_TOKEN secret if stale","Check that the sentry_id in the issue body is a valid event id for this org"],"exampleFix":"// before\nif (!response.ok) {\n  throw new Error(`Failed to fetch Sentry event: ${response.statusText}`);\n}\n\n// after\nif (!response.ok) {\n  const detail = await response.text();\n  throw new Error(`Failed to fetch Sentry event: ${response.status} ${response.statusText} ${detail.slice(0, 200)}`);\n}","handlingStrategy":"try-catch","validationCode":"null","typeGuard":null,"tryCatchPattern":"try {\n  await associateIssue();\n} catch (err) {\n  if (/Failed to fetch Sentry event/.test(err.message)) {\n    core.warning(`Sentry lookup failed (token or event id): ${err.message}`);\n    return; // non-fatal: leave the issue unassociated\n  }\n  throw err;\n}","preventionTips":["Smoke-test SENTRY_AUTH_TOKEN against one known event URL before the run","Include response body in errors to distinguish 401/403 vs 404"],"tags":["sentry","http","authentication","api"],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}