diegosouzapw/OmniRoute · error · CodexAuthFileError
Only Codex provider connections can export Codex auth files
Error message
Only Codex provider connections can export Codex auth files
What it means
Guard in resolveFreshCodexConnection: the requested connection exists in the DB but its provider field is not 'codex'. Export of Codex auth.json is only meaningful for Codex-type connections; a non-codex connection passed by id is a caller-side input error.
Solutions
- Verify the connectionId passed to buildCodexAuthFile/export actually points to a Codex connection
- List connections filtered by provider=codex and pick the right id
- Create a Codex connection first if none exists
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/lib/oauth/utils/codexAuthFile.ts:206 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25).
Data as JSON: /api/errors/84204386d3157118.
Report an issue: GitHub.
Appendix: source
Thrown at src/lib/oauth/utils/codexAuthFile.ts:206
OPENAI_API_KEY: null,
tokens: {
id_token: idToken,
access_token: accessToken,
refresh_token: refreshToken,
account_id: accountId,
},
last_refresh: new Date().toISOString(),
};
}
async function resolveFreshCodexConnection(connectionId: string): Promise<CodexConnectionLike> {
const connection = (await getCachedProviderConnectionById(connectionId)) as CodexConnectionLike | null;
if (!connection) {
throw new CodexAuthFileError("Connection not found", 404, "not_found");
}
if (connection.provider !== "codex") {
throw new CodexAuthFileError("Only Codex provider connections can export Codex auth files");
}
if (connection.authType !== "oauth") {
throw new CodexAuthFileError("Only OAuth Codex connections support auth.json export");
}
if (!shouldRefreshCodexConnection(connection)) {
return connection;
}
const refreshToken = toNonEmptyString(connection.refreshToken);
if (!refreshToken) {
throw new CodexAuthFileError(
"Codex connection requires refresh but no refresh_token is available. Re-authenticate first.",
409,
"reauth_required"
);
}View on GitHub (pinned to a179ffed5b)