{"record":{"id":"7423bf1a6c385495","repo":"Yeachan-Heo/oh-my-codex","slug":"codex-login-exited-with-code-result-status-1","errorCode":null,"errorMessage":"codex login exited with code ${result.status ?? 1}","messagePattern":"codex login exited with code (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cli/auth.ts","lineNumber":55,"sourceCode":"}\n\nfunction runCodexLogin(cwd: string, env: NodeJS.ProcessEnv, loginArgs: string[] = []): void {\n  validateCodexLoginArgs(loginArgs);\n  const { result } = spawnPlatformCommandSync(\"codex\", [\"login\", ...loginArgs], {\n    cwd,\n    env,\n    stdio: \"inherit\",\n    encoding: \"utf-8\",\n  });\n  if (result.error) {\n    const error = result.error as NodeJS.ErrnoException;\n    const kind = classifySpawnError(error);\n    if (kind === \"missing\") throw new Error(\"failed to launch codex login: executable not found in PATH\");\n    if (kind === \"blocked\") throw new Error(`failed to launch codex login: executable is blocked (${error.code || \"blocked\"})`);\n    throw error;\n  }\n  if (result.status !== 0) {\n    throw new Error(`codex login exited with code ${result.status ?? 1}`);\n  }\n}\nasync function fileExists(path: string): Promise<boolean> {\n  try {\n    await readFile(path);\n    return true;\n  } catch (error) {\n    if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return false;\n    throw error;\n  }\n}\n\nasync function createIsolatedLoginCodexHome(home: string | undefined): Promise<string> {\n  const base = join(home || homedir(), \".omx\");\n  await mkdir(base, { recursive: true, mode: 0o700 });\n  return await mkdtemp(join(base, \"auth-login-\"));\n}\n","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/cli/auth.ts#L37-L73","documentation":"The codex login child process launched successfully but exited with a non-zero status; omx propagates that exit code as an error. The underlying cause is whatever made codex login fail (cancelled device flow, invalid API key, network error), and codex's own output (inherited stdio) appears above this error.","triggerScenarios":"Completing/aborting `codex login` interactively and choosing failure, passing an invalid key via --with-api-key, codex hitting network/auth-server errors, or the user pressing Ctrl+C during the device-auth flow.","commonSituations":"Expired or mistyped API keys; device-auth timeout; corporate proxies breaking codex's auth endpoints; user cancelling the browser flow.","solutions":["Read the codex output printed before the error — it names the actual failure","Retry the login and complete the device-auth flow within the time limit","For --with-api-key/--with-access-token, verify the credential is valid and not expired","Check network/proxy access to the codex auth endpoints"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-validate credentials where possible before login\nif (mode === '--with-api-key' && !/^(sk-)?[A-Za-z0-9_-]{20,}$/.test(key)) throw new Error('key looks invalid');","typeGuard":null,"tryCatchPattern":"catch (e) { const m = /codex login exited with code (\\d+)/.exec(String(e)); if (m) { reportAuthFailure(+m[1]); } else throw e; }","preventionTips":["Complete device-auth flows promptly to avoid timeouts","Validate API keys before passing them","Check proxy/network connectivity to auth endpoints first"],"tags":["auth","codex","non-zero-exit","login"],"backgroundTag":"subprocess-non-zero-exit","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}