{"record":{"id":"cbae48f289bef5b0","repo":"diegosouzapw/OmniRoute","slug":"refresh-failed-cbae48","errorCode":"refresh_failed","errorMessage":"Failed to refresh the Codex session before exporting the auth file. Re-authenticate this account if the session is stale.","messagePattern":"Failed to refresh the Codex session before exporting the auth file\\. Re-authenticate this account if the session is stale\\.","errorType":"exception","errorClass":"CodexAuthFileError","httpStatus":502,"severity":"error","filePath":"src/lib/oauth/utils/codexAuthFile.ts","lineNumber":254,"sourceCode":"      idToken: connection.idToken,\n      providerSpecificData: connection.providerSpecificData,\n    },\n    async (result) => {\n      await updateProviderCredentials(connectionId, result);\n      persistedRefresh = result;\n    }\n  );\n\n  if (isUnrecoverableRefreshError(refreshed)) {\n    throw new CodexAuthFileError(\n      \"Codex refresh token is no longer valid. Re-authenticate this account before exporting.\",\n      409,\n      \"reauth_required\"\n    );\n  }\n\n  if (!refreshed?.accessToken) {\n    throw new CodexAuthFileError(\n      \"Failed to refresh the Codex session before exporting the auth file. Re-authenticate this account if the session is stale.\",\n      502,\n      \"refresh_failed\"\n    );\n  }\n\n  // If onPersist was not triggered (no accessToken path), fall back to explicit persist.\n  if (!persistedRefresh) {\n    await updateProviderCredentials(connectionId, refreshed);\n  }\n\n  const effectiveExpiresAt = refreshed.expiresAt\n    ? refreshed.expiresAt\n    : typeof refreshed.expiresIn === \"number\"\n      ? new Date(Date.now() + refreshed.expiresIn * 1000).toISOString()\n      : connection.expiresAt || null;\n\n  return {","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/oauth/utils/codexAuthFile.ts#L236-L272","documentation":"Error \"Failed to refresh the Codex session before exporting the auth file. Re-authenticate this account if the session is stale.\" thrown in diegosouzapw/OmniRoute.","triggerScenarios":"Thrown at src/lib/oauth/utils/codexAuthFile.ts:254 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"}