{"record":{"id":"0a031b7dc69f55d9","repo":"diegosouzapw/OmniRoute","slug":"missing-refresh-token","errorCode":"missing_refresh_token","errorMessage":"refresh_token is missing or empty in the agy token file","messagePattern":"refresh_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":87,"sourceCode":" */\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) {\n    const ms = new Date(isoExpiry).getTime();\n    expiresAt = Number.isNaN(ms) ? null : new Date(ms).toISOString();\n  } else if (typeof token.expiry_date === \"number\" && Number.isFinite(token.expiry_date)) {\n    expiresAt = new Date(token.expiry_date).toISOString();\n  }\n\n  const tokenType = toNonEmptyString(token.token_type) ?? \"Bearer\";\n  const authMethod = toNonEmptyString(doc.auth_method) ?? toNonEmptyString(token.auth_method);","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/oauth/utils/agyAuthImport.ts#L69-L105","documentation":"Error \"refresh_token is missing or empty in the agy token file\" thrown in diegosouzapw/OmniRoute.","triggerScenarios":"Thrown at src/lib/oauth/utils/agyAuthImport.ts:87 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","schemaVersion":2},"datasetVersion":"2026-08-25T21:54:21.419Z"}