oven-sh/bun · error · Error

Failed to fetch Sentry issue

Error message

Failed to fetch Sentry issue: ${issueResponse.statusText}

What it means

The follow-up call GET /api/0/issues/<groupId>/ returned non-2xx. The groupId came from the previous event lookup, so failures here usually mean the group was deleted/merged, the token cannot see it, or the id is invalid for this org.

Solutions

  1. curl the issue URL with the same token and inspect the status and body
  2. Widen the token scopes (org:read + project:read / event:read covering issues)
  3. Handle 404 by skipping association for groups that no longer exist

Example fix

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

// after
if (!issueResponse.ok) {
  if (issueResponse.status === 404) {
    console.log(`Sentry issue ${groupId} gone; skipping`);
    process.exit(0);
  }
  throw new Error(`Failed to fetch Sentry issue: ${issueResponse.status} ${issueResponse.statusText}`);
}
Defensive patterns

Strategy: try-catch

Validate before calling

null

Try / catch

try {
  await fetchIssue(groupId);
} catch (err) {
  if (/Failed to fetch Sentry issue/.test(err.message) && /404/.test(err.message)) {
    core.info('group no longer exists; skipping');
    return;
  }
  throw err;
}

Prevention

When it happens

Trigger: Group resolved by the event endpoint but since deleted or merged in Sentry; token scopes allow event reads but not issue reads; groupId is from a different org.

Common situations: Issues merged in the Sentry dashboard between the two calls; token with narrow scopes; stale groupId from an old event.

Related errors


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

Appendix: source

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

    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");
}

console.log(`Sentry ID: ${shortId}`);
console.log(`Sentry permalink: ${permalink}`);

await Bun.write("sentry-id.txt", shortId);
await Bun.write("sentry-link.txt", permalink);

export {};

View on GitHub (pinned to 8c5296ac45)