oven-sh/bun · error · Error

Failed to fetch Sentry event: ${response.statusText}

Error message

Failed to fetch Sentry event: ${response.statusText}

What it means

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.

Source

Thrown at scripts/associate-issue-with-sentry.ts:24

}

const id = body.indexOf("<!-- sentry_id: ");
const endIdLine = body.indexOf(" -->", id + 1);
if (!(id > -1 && endIdLine > -1)) {
  throw new Error("Missing sentry_id");
}
const sentryId = body.slice(id + "<!-- sentry_id: ".length, endIdLine).trim();
if (!sentryId) {
  throw new Error("Missing sentry_id");
}

const response = await fetch(`https://sentry.io/api/0/organizations/4507155222364160/eventids/${sentryId}/`, {
  headers: {
    Authorization: `Bearer ${SENTRY_AUTH_TOKEN}`,
  },
});
if (!response.ok) {
  throw new Error(`Failed to fetch Sentry event: ${response.statusText}`);
}
const json = await response.json();
const groupId = json?.groupId;
if (!groupId) {
  throw new Error("Missing groupId");
}

const issueResponse = await fetch(`https://sentry.io/api/0/issues/${groupId}/`, {
  headers: {
    Authorization: `Bearer ${SENTRY_AUTH_TOKEN}`,
  },
});
if (!issueResponse.ok) {
  throw new Error(`Failed to fetch Sentry issue: ${issueResponse.statusText}`);
}
const { shortId, permalink } = await issueResponse.json();
if (!shortId || !permalink) {
  throw new Error("Missing shortId or permalink");

View on GitHub (pinned to 8c5296ac45)

Solutions

  1. Verify the token: curl -H 'Authorization: Bearer $SENTRY_AUTH_TOKEN' the same URL and inspect the real status/body
  2. Confirm the token has read scope on organization 4507155222364160 and update the SENTRY_AUTH_TOKEN secret if stale
  3. Check that the sentry_id in the issue body is a valid event id for this org

Example fix

// before
if (!response.ok) {
  throw new Error(`Failed to fetch Sentry event: ${response.statusText}`);
}

// after
if (!response.ok) {
  const detail = await response.text();
  throw new Error(`Failed to fetch Sentry event: ${response.status} ${response.statusText} ${detail.slice(0, 200)}`);
}
Defensive patterns

Strategy: try-catch

Validate before calling

null

Try / catch

try {
  await associateIssue();
} catch (err) {
  if (/Failed to fetch Sentry event/.test(err.message)) {
    core.warning(`Sentry lookup failed (token or event id): ${err.message}`);
    return; // non-fatal: leave the issue unassociated
  }
  throw err;
}

Prevention

When it happens

Trigger: 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.

Common situations: Rotated Sentry auth token not updated in GitHub secrets; issue marker edited with a wrong id; old issues reprocessed after retention expiry.

Related errors


AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16). Data as JSON: /api/errors/00cd4e6dbea8f928. Report an issue: GitHub.