koala73/worldmonitor · error · Error

Set SENTRY_AUTH_TOKEN (or SENTRY_SESSION_TOKEN) to a `sntryu

Error message

Set SENTRY_AUTH_TOKEN (or SENTRY_SESSION_TOKEN) to a `sntryu_` user token with `event:read` and `project:read`, or pass --input <path> to audit a saved payload.

What it means

main() only fetches live Sentry data when no --input file is given, and in that path it requires a bearer token. If neither SENTRY_SESSION_TOKEN nor SENTRY_AUTH_TOKEN is set in the environment, it throws this error telling the operator to supply a `sntryu_` user token or audit a saved payload instead.

Solutions

  1. Export SENTRY_AUTH_TOKEN (or SENTRY_SESSION_TOKEN) with a `sntryu_` user token carrying `event:read` and `project:read`.
  2. Or pass a saved payload: `node scripts/audit-sentry-resolve-pins.mjs --input <path-to-issues.json>`.
  3. In CI, confirm the secret is actually defined in the workflow/pipeline environment and the variable name matches exactly.
  4. Check the token value is non-empty (an empty export still fails this check).

Example fix

// before
SENTRY_TOKEN=sntryu_... npm run audit:sentry  # wrong var name
// after
SENTRY_AUTH_TOKEN=sntryu_... npm run audit:sentry
Defensive patterns

Strategy: validation

Validate before calling

// fail fast at script start with a clear message
const token = process.env.SENTRY_SESSION_TOKEN || process.env.SENTRY_AUTH_TOKEN;
if (!token && !process.argv.includes('--input')) {
  console.error('Set SENTRY_AUTH_TOKEN (sntryu_ user token) or pass --input <path>');
  process.exit(1);
}

Prevention

When it happens

Trigger: Running `node scripts/audit-sentry-resolve-pins.mjs` (or npm script wrapping it) with no --input flag while both `process.env.SENTRY_SESSION_TOKEN` and `process.env.SENTRY_AUTH_TOKEN` are unset or empty strings.

Common situations: Running the audit locally without sourcing the env file; CI job where the secret was never injected or is under a different variable name; a .env file not loaded; typo in the variable name (e.g. SENTRY_TOKEN); empty-string export in CI.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of koala73/worldmonitor@7d06c8633d (2026-09-15). Data as JSON: /api/errors/a0e6c514643ac090. Report an issue: GitHub.

Appendix: source

Thrown at scripts/audit-sentry-resolve-pins.mjs:265

    }
    url = sameOriginCursor(next);
  }

  throw new Error(`Sentry issues pagination exceeded ${MAX_PAGES} pages`);
}

async function main() {
  const args = parseArguments(process.argv.slice(2));
  const org = process.env.SENTRY_ORG || DEFAULT_ORG;
  const project = process.env.SENTRY_PROJECT || DEFAULT_PROJECT;

  let issues;
  if (args.input) {
    issues = JSON.parse(readFileSync(args.input, 'utf8'));
  } else {
    const token = process.env.SENTRY_SESSION_TOKEN || process.env.SENTRY_AUTH_TOKEN;
    if (!token) {
      throw new Error(
        'Set SENTRY_AUTH_TOKEN (or SENTRY_SESSION_TOKEN) to a `sntryu_` user token with '
          + '`event:read` and `project:read`, or pass --input <path> to audit a saved payload.',
      );
    }
    issues = await fetchResolvedIssues(token, org, project);
  }

  const result = auditResolvedIssues(issues);
  console.log(formatReport(result));

  if (result.violations.length > 0) {
    for (const violation of result.violations) {
      console.error(
        `::error::${violation.shortId ?? violation.id} is resolved and pinned to `
          + `${violation.pinValue}; deployed release compatibility needs verification.`,
      );
    }
    console.error(formatRepairRecipe());

View on GitHub (pinned to 7d06c8633d)