oven-sh/bun · error · Error
Missing environment variables
Error message
Missing environment variables
What it means
Top-of-script guard in a GitHub Action helper that links Sentry crash events to GitHub issues. It requires both GITHUB_ISSUE_BODY (the issue text injected by the workflow) and SENTRY_AUTH_TOKEN (a Sentry API token). If either is unset or empty the script has nothing to work with and aborts before making any request.
Source
Thrown at scripts/associate-issue-with-sentry.ts:5
const body = process.env.GITHUB_ISSUE_BODY;
const SENTRY_AUTH_TOKEN = process.env.SENTRY_AUTH_TOKEN;
if (!body || !SENTRY_AUTH_TOKEN) {
throw new Error("Missing environment variables");
}
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) {View on GitHub (pinned to 8c5296ac45)
Solutions
- Run the script with both variables: GITHUB_ISSUE_BODY="$ISSUE_BODY" SENTRY_AUTH_TOKEN=sntrys_... bun scripts/associate-issue-with-sentry.ts
- Add SENTRY_AUTH_TOKEN from repository secrets to the step's env: block in the workflow
- Confirm both secrets exist and are non-empty under GitHub Settings > Secrets and variables > Actions
Example fix
# before
- run: bun scripts/associate-issue-with-sentry.ts
# after
- run: bun scripts/associate-issue-with-sentry.ts
env:
GITHUB_ISSUE_BODY: ${{ github.event.issue.body }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} Defensive patterns
Strategy: validation
Validate before calling
const body = process.env.GITHUB_ISSUE_BODY;
const token = process.env.SENTRY_AUTH_TOKEN;
if (!body || !token) {
console.error('missing env:', !body ? 'GITHUB_ISSUE_BODY' : 'SENTRY_AUTH_TOKEN');
process.exit(1);
} Prevention
- Always map required env in the workflow step's env: block from secrets and event payloads
- Fail fast in a preflight check rather than mid-script
When it happens
Trigger: Invoking scripts/associate-issue-with-sentry.ts outside its workflow without sourcing the env; a workflow step whose env: block forgot to pass GITHUB_ISSUE_BODY or SENTRY_AUTH_TOKEN; a repository secret that was deleted or resolves to an empty string.
Common situations: Local dry-run of the script without the Action's env; workflow edited and env mapping dropped; Sentry token secret rotated away or removed from the repo.
Related errors
- Missing sentry_id
- GITHUB_TOKEN environment variable is required
- GITHUB_ISSUE_NUMBER must be set
- GITHUB_ISSUE_BODY must be set
- Missing global bin directory: try setting $BUN_INSTALL
AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16).
Data as JSON: /api/errors/41024cd3196901c2.
Report an issue: GitHub.