{"record":{"id":"a0e6c514643ac090","repo":"koala73/worldmonitor","slug":"set-sentry-auth-token-or-sentry-session-token-to-a-sntryu","errorCode":null,"errorMessage":"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.","messagePattern":"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\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/audit-sentry-resolve-pins.mjs","lineNumber":265,"sourceCode":"    }\n    url = sameOriginCursor(next);\n  }\n\n  throw new Error(`Sentry issues pagination exceeded ${MAX_PAGES} pages`);\n}\n\nasync function main() {\n  const args = parseArguments(process.argv.slice(2));\n  const org = process.env.SENTRY_ORG || DEFAULT_ORG;\n  const project = process.env.SENTRY_PROJECT || DEFAULT_PROJECT;\n\n  let issues;\n  if (args.input) {\n    issues = JSON.parse(readFileSync(args.input, 'utf8'));\n  } else {\n    const token = process.env.SENTRY_SESSION_TOKEN || process.env.SENTRY_AUTH_TOKEN;\n    if (!token) {\n      throw new Error(\n        'Set SENTRY_AUTH_TOKEN (or SENTRY_SESSION_TOKEN) to a `sntryu_` user token with '\n          + '`event:read` and `project:read`, or pass --input <path> to audit a saved payload.',\n      );\n    }\n    issues = await fetchResolvedIssues(token, org, project);\n  }\n\n  const result = auditResolvedIssues(issues);\n  console.log(formatReport(result));\n\n  if (result.violations.length > 0) {\n    for (const violation of result.violations) {\n      console.error(\n        `::error::${violation.shortId ?? violation.id} is resolved and pinned to `\n          + `${violation.pinValue}; deployed release compatibility needs verification.`,\n      );\n    }\n    console.error(formatRepairRecipe());","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/koala73/worldmonitor/blob/7d06c8633d256c18e38133030bc3613976a96ec9/scripts/audit-sentry-resolve-pins.mjs#L247-L283","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Export SENTRY_AUTH_TOKEN (or SENTRY_SESSION_TOKEN) with a `sntryu_` user token carrying `event:read` and `project:read`.","Or pass a saved payload: `node scripts/audit-sentry-resolve-pins.mjs --input <path-to-issues.json>`.","In CI, confirm the secret is actually defined in the workflow/pipeline environment and the variable name matches exactly.","Check the token value is non-empty (an empty export still fails this check)."],"exampleFix":"// before\nSENTRY_TOKEN=sntryu_... npm run audit:sentry  # wrong var name\n// after\nSENTRY_AUTH_TOKEN=sntryu_... npm run audit:sentry","handlingStrategy":"validation","validationCode":"// fail fast at script start with a clear message\nconst token = process.env.SENTRY_SESSION_TOKEN || process.env.SENTRY_AUTH_TOKEN;\nif (!token && !process.argv.includes('--input')) {\n  console.error('Set SENTRY_AUTH_TOKEN (sntryu_ user token) or pass --input <path>');\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Load the project .env (via the repo's loadEnvFile helper) before invoking the audit.","Keep the token defined in CI as a named secret and inject it into env explicitly.","Use the exact variable names SENTRY_AUTH_TOKEN / SENTRY_SESSION_TOKEN — no aliases.","Keep a saved issues payload handy so --input is a viable offline fallback."],"tags":["sentry","env-var","auth-token","missing-credentials"],"backgroundTag":"missing-env-var","analyzedSha":"7d06c8633d256c18e38133030bc3613976a96ec9","analyzedAt":"2026-09-15T16:44:39.439Z","contentChangedAt":"2026-09-15T16:44:39.439Z","schemaVersion":2},"datasetVersion":"2026-09-15T18:17:12.389Z"}