oven-sh/bun · error
GITHUB_ISSUE_NUMBER must be set
Error message
GITHUB_ISSUE_NUMBER must be set
What it means
scripts/handle-crash-patterns.ts is a GitHub Actions automation script that triages crash-report issues; it requires GITHUB_ISSUE_NUMBER to know which issue to comment on or close. It throws at startup when the env var is unset or empty.
Source
Thrown at scripts/handle-crash-patterns.ts:8
#!/usr/bin/env bun
const body = process.env.GITHUB_ISSUE_BODY || "";
const title = process.env.GITHUB_ISSUE_TITLE || "";
const issueNumber = process.env.GITHUB_ISSUE_NUMBER;
if (!issueNumber) {
throw new Error("GITHUB_ISSUE_NUMBER must be set");
}
interface CloseAction {
reason: "not_planned" | "completed";
comment: string;
}
let closeAction: CloseAction | null = null;
// Compute lowercase once for performance
const bodyLower = body.toLowerCase();
// Check for workers_terminated
if (bodyLower.includes("workers_terminated")) {
closeAction = {
reason: "not_planned",
comment: `Duplicate of #15964
We are tracking worker stability issues in https://github.com/oven-sh/bun/issues/15964. For now, I recommend against terminating workers when possible.`,View on GitHub (pinned to 8c5296ac45)
Solutions
- Add `GITHUB_ISSUE_NUMBER: ${{ github.event.issue.number }}` to the step's env in the workflow
- Gate the step/job with `if: github.event_name == 'issues'` so it never runs without an issue
- For local testing: `GITHUB_ISSUE_NUMBER=123 GITHUB_ISSUE_TITLE='...' GITHUB_ISSUE_BODY='...' bun scripts/handle-crash-patterns.ts`
Example fix
# before (workflow step)
- run: bun scripts/handle-crash-patterns.ts
env:
GITHUB_ISSUE_BODY: ${{ github.event.issue.body }}
# after
- run: bun scripts/handle-crash-patterns.ts
if: github.event_name == 'issues'
env:
GITHUB_ISSUE_NUMBER: ${{ github.event.issue.number }}
GITHUB_ISSUE_TITLE: ${{ github.event.issue.title }}
GITHUB_ISSUE_BODY: ${{ github.event.issue.body }} Defensive patterns
Strategy: validation
Validate before calling
function parseIssueNumber(raw = process.env.GITHUB_ISSUE_NUMBER): number {
const n = Number(raw);
if (!Number.isInteger(n) || n <= 0) {
throw new Error('GITHUB_ISSUE_NUMBER must be set to a positive issue number');
}
return n;
} Type guard
const isIssueNumber = (v: unknown): v is number => typeof v === 'number' && Number.isInteger(v) && v > 0;
Prevention
- Gate Actions steps with `if: github.event_name == 'issues'` when they need issue context
- Mirror every GITHUB_ISSUE_* env var together — the scripts use them as a set
- Dry-run locally with all three env vars exported before pushing workflow changes
When it happens
Trigger: The workflow step runs under a trigger that has no issue context (schedule, push, workflow_dispatch) because the step isn't gated with `if: github.event.issue`; running the script locally without exporting the env var; the env var was renamed in the workflow YAML.
Common situations: Copy-pasting the automation step into a new workflow/trigger; local testing of the script; a refactor of the env block dropping GITHUB_ISSUE_NUMBER.
Related errors
- GITHUB_ISSUE_BODY must be set
- Missing environment variables
- Missing sentry_id
- BUILDKITE_AGENT_TOKEN not set and no existing buildkite-agen
- Buildkite token not found: set BUILDKITE_AGENT_TOKEN or gran
AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16).
Data as JSON: /api/errors/8cf4f2ea5e141374.
Report an issue: GitHub.