diegosouzapw/OmniRoute · error · CodexAuthFileError
account_id_missing
account_id_missing
Error message
Unable to derive Codex account_id from the stored session. Re-authenticate this account.
What it means
Account-resolution failure in buildCodexAuthPayload: id_token and both tokens are present, but extractCodexAccountId(idToken, providerSpecificData) could not derive the ChatGPT account_id (normally decoded from the id_token claims or fallback provider-specific data). Without account_id the exported Codex auth.json is unusable, so a 409 reauth_required error is thrown.
Solutions
- Re-authenticate the account to mint a fresh id_token containing the account claim
- Inspect the id_token JWT payload to see which claim (e.g. chatgpt_account_id / auth_user) is missing
- Check providerSpecificData for a stored account id fallback
- Update extractCodexAccountId if OpenAI renamed the claim
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/lib/oauth/utils/codexAuthFile.ts:179 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25).
Data as JSON: /api/errors/0680ed272309181c.
Report an issue: GitHub.
Appendix: source
Thrown at src/lib/oauth/utils/codexAuthFile.ts:179
if (!accessToken) {
throw new CodexAuthFileError(
"Codex connection is missing access_token. Refresh or re-authenticate this account first.",
409,
"access_token_missing"
);
}
if (!refreshToken) {
throw new CodexAuthFileError(
"Codex connection is missing refresh_token. Re-authenticate this account before exporting.",
409,
"reauth_required"
);
}
const accountId = extractCodexAccountId(idToken, connection.providerSpecificData);
if (!accountId) {
throw new CodexAuthFileError(
"Unable to derive Codex account_id from the stored session. Re-authenticate this account.",
409,
"account_id_missing"
);
}
return {
auth_mode: "chatgpt",
OPENAI_API_KEY: null,
tokens: {
id_token: idToken,
access_token: accessToken,
refresh_token: refreshToken,
account_id: accountId,
},
last_refresh: new Date().toISOString(),
};
}View on GitHub (pinned to a179ffed5b)