oven-sh/bun · error · Error

Missing groupId

Error message

Missing groupId

What it means

The event lookup succeeded (2xx) but the parsed JSON has no groupId field. Sentry assigns each event to an issue group; a missing groupId means the payload shape changed or the event has no associated group yet, so the follow-up issue lookup cannot proceed.

Source

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

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

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

View on GitHub (pinned to 8c5296ac45)

Solutions

  1. Log the full response body to see what Sentry actually returned
  2. Retry once after a short delay if grouping may still be in flight
  3. Pin or adapt to the documented response shape for the eventids endpoint

Example fix

// before
const groupId = json?.groupId;
if (!groupId) throw new Error('Missing groupId');

// after
const groupId = json?.groupId;
if (!groupId) {
  throw new Error(`Missing groupId in response: ${JSON.stringify(json).slice(0, 200)}`);
}
Defensive patterns

Strategy: type-guard

Validate before calling

null

Type guard

function hasGroupId(json: unknown): json is { groupId: string } {
  return typeof json === 'object' && json !== null && typeof (json as any).groupId === 'string' && (json as any).groupId.length > 0;
}

Prevention

When it happens

Trigger: Sentry API returns a success envelope without grouping info (event ingested but not grouped, or a shape change in the eventids endpoint); json is an error object rather than an event.

Common situations: Upstream Sentry API contract drift; polling an event immediately after ingestion before grouping completes.

Related errors


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