{"record":{"id":"9a011a881260abb1","repo":"vercel-labs/agent-skills","slug":"not-auth","errorCode":"NOT_AUTH","errorMessage":"NOT_AUTH: run `vercel login`.","messagePattern":"NOT_AUTH: run `vercel login`\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"skills/vercel-optimize/lib/vercel.mjs","lineNumber":119,"sourceCode":"  const m = raw.match(/(\\d+)\\.(\\d+)\\.(\\d+)/);\n  if (!m) throw new Error(`VERCEL_VERSION_UNPARSEABLE: ${raw}`);\n  const v = [Number(m[1]), Number(m[2]), Number(m[3])];\n  for (let i = 0; i < 3; i++) {\n    if (v[i] > MIN_CLI_VERSION[i]) return v;\n    if (v[i] < MIN_CLI_VERSION[i]) {\n      throw new Error(\n        `VERCEL_CLI_TOO_OLD: have ${v.join('.')}, need >= ${MIN_CLI_VERSION.join('.')}. Upgrade with \\`npm i -g vercel@latest\\`.`\n      );\n    }\n  }\n  return v;\n}\n\nexport async function checkAuth() {\n  try {\n    await runVercel(['whoami']);\n  } catch {\n    throw new Error('NOT_AUTH: run `vercel login`.');\n  }\n}\n\nexport async function getCliIdentity() {\n  const r = await runVercelJson(['whoami', '--format', 'json']);\n  return r.ok ? r.data : null;\n}\n\n// Supports newer `.vercel/repo.json` (multi-project) + legacy `.vercel/project.json` (single-project).\nexport async function readProjectJson(cwd = process.cwd()) {\n  try {\n    const raw = await readFile(join(cwd, '.vercel', 'repo.json'), 'utf-8');\n    const parsed = JSON.parse(raw);\n    const projects = Array.isArray(parsed?.projects) ? parsed.projects.filter((p) => p?.id) : [];\n    if (projects.length > 1) {\n      throw new Error('AMBIGUOUS_PROJECT_LINK: `.vercel/repo.json` contains multiple projects. Run from the linked app directory, or pass the intended projectId together with VERCEL_ORG_ID.');\n    }\n    const first = projects[0];","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/vercel-labs/agent-skills/blob/b8caa260a420a73042e35521de4b5c8baf6446cc/skills/vercel-optimize/lib/vercel.mjs#L101-L137","documentation":"Thrown by checkAuth() when `runVercel(['whoami'])` rejects. `vercel whoami` exits non-zero when there is no authenticated session, so the rejection indicates the CLI is not logged in. The collector needs an authed session to run every scoped subcommand, so this is a hard gate placed right after the version check.","triggerScenarios":"Running collect-signals on a machine/environment that never ran `vercel login`; a CI runner using token auth where VERCEL_TOKEN is unset or expired; a session that was revoked from the Vercel dashboard; `vercel logout` run earlier in the same shell.","commonSituations":"Fresh checkout in CI with no token injected; a shared machine where another user logged out; token expired; team SSO re-issued and the local token is stale.","solutions":["Run `vercel login` interactively and re-run the script.","For CI/headless, set VERCEL_TOKEN (or run `vercel login --token`) with a valid deployment token, then confirm `vercel whoami` succeeds.","If the token was revoked, generate a new one in the Vercel dashboard and update the secret."],"exampleFix":"# before\n$ node scripts/collect-signals.mjs\n-> NOT_AUTH: run `vercel login`.\n\n# after\n$ vercel login\n$ vercel whoami   # sanity check, should print your username\n$ node scripts/collect-signals.mjs","handlingStrategy":"validation","validationCode":"import { execFileSync } from 'node:child_process';\nfunction assertAuthed() {\n  try { execFileSync('vercel', ['whoami'], { stdio: 'pipe' }); }\n  catch { throw new Error('Not logged in. Run `vercel login` or set VERCEL_TOKEN.'); }\n}\nassertAuthed();","typeGuard":null,"tryCatchPattern":"try {\n  await checkAuth();\n} catch (err) {\n  if (err.message.startsWith('NOT_AUTH')) {\n    // prompt login flow, then retry\n    throw new Error('Run `vercel login`, then rerun this script.');\n  }\n  throw err;\n}","preventionTips":["In CI, inject a valid VERCEL_TOKEN and assert `vercel whoami` in a precheck.","Rotate tokens before expiry and update the secret.","Avoid `vercel logout` in shared environments."],"tags":["auth","cli","credentials","vercel"],"backgroundTag":null,"analyzedSha":"b8caa260a420a73042e35521de4b5c8baf6446cc","analyzedAt":"2026-08-13T06:03:29.508Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}