{"record":{"id":"26de4e7c8546a7ef","repo":"diegosouzapw/OmniRoute","slug":"missing-access-token","errorCode":"missing_access_token","errorMessage":"access_token is missing or empty in the agy token file","messagePattern":"access_token is missing or empty in the agy token file","errorType":"exception","errorClass":"AgyAuthFileError","httpStatus":400,"severity":"error","filePath":"src/lib/oauth/utils/agyAuthImport.ts","lineNumber":79,"sourceCode":"}\n\n// ──── Parse & validate ────────────────────────────────────────────────────────\n\n/**\n * Parse the Antigravity CLI (`agy`) token file. It nests the token under `.token`,\n * uses an ISO `expiry` string, and has NO `id_token`. A flat top-level shape is\n * accepted as a fallback.\n */\nexport function parseAndValidateAgyToken(raw: unknown): ParsedAgyAuth {\n  const doc = toRecord(raw);\n  // agy nests credentials under `.token`; fall back to the top level for flat exports.\n  const token = doc.token && typeof doc.token === \"object\" ? toRecord(doc.token) : doc;\n\n  const accessToken = toNonEmptyString(token.access_token);\n  const refreshToken = toNonEmptyString(token.refresh_token);\n\n  if (!accessToken) {\n    throw new AgyAuthFileError(\n      \"access_token is missing or empty in the agy token file\",\n      400,\n      \"missing_access_token\"\n    );\n  }\n\n  if (!refreshToken) {\n    throw new AgyAuthFileError(\n      \"refresh_token is missing or empty in the agy token file\",\n      400,\n      \"missing_refresh_token\"\n    );\n  }\n\n  // agy uses an ISO `expiry`; also accept a unix-ms `expiry_date`/`expires_at` for safety.\n  let expiresAt: string | null = null;\n  const isoExpiry = toNonEmptyString(token.expiry) ?? toNonEmptyString(token.expires_at);\n  if (isoExpiry) {","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/oauth/utils/agyAuthImport.ts#L61-L97","documentation":"Structural validation in parseAndValidateAgyToken: after resolving the token record (nested under .token, or flat top-level fallback), access_token is missing or empty. The imported Antigravity CLI (agy) token file does not contain usable credentials, so import is refused with a 400 missing_access_token error.","triggerScenarios":"Thrown at src/lib/oauth/utils/agyAuthImport.ts:79 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-export the auth file from the agy CLI while signed in so access_token is populated","Confirm the file shape: credentials may be nested under .token; a malformed hand-edit can drop the field","Reject obviously empty token files in the UI before parsing"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}