{"record":{"id":"e97b4002f20ca13b","repo":"stablyai/orca","slug":"a-codex-home-directory-path-is-required","errorCode":null,"errorMessage":"A Codex home directory path is required.","messagePattern":"A Codex home directory path is required\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/codex-accounts/service.ts","lineNumber":764,"sourceCode":"      this.importCodexAuthFromHome(sourceHome, managedHomePath, accountId)\n      return await this.persistCapturedCodexAccount(accountId, managedHome)\n    } catch (error) {\n      this.safeRemoveManagedHome(managedHomePath, accountId)\n      throw error\n    }\n  }\n\n  // Why: copy the auth.json from an already-authenticated CODEX_HOME (e.g. a temp\n  // dir the CLI ran `codex login` into) into the managed home. Mirrors the login\n  // step of doAddAccount without spawning an interactive browser flow.\n  private importCodexAuthFromHome(\n    sourceHome: string,\n    managedHomePath: string,\n    accountId: string\n  ): void {\n    const trimmed = sourceHome.trim()\n    if (!trimmed) {\n      throw new Error('A Codex home directory path is required.')\n    }\n    const authPath = join(resolve(trimmed), 'auth.json')\n    if (!existsSync(authPath)) {\n      throw new Error(\n        `No Codex credentials found in ${resolve(trimmed)}. Run \\`codex login\\` into this directory first.`\n      )\n    }\n    const trustedHome = this.assertManagedHomePath(managedHomePath, accountId)\n    writeFileAtomically(join(trustedHome, 'auth.json'), readFileSync(authPath, 'utf-8'), {\n      mode: 0o600\n    })\n  }\n\n  private async persistCapturedCodexAccount(\n    accountId: string,\n    managedHome: ManagedHomeLocation\n  ): Promise<CodexRateLimitAccountsState> {\n    const identity = this.readIdentityFromHome(managedHome.managedHomePath, accountId)","sourceCodeStart":746,"sourceCodeEnd":782,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/codex-accounts/service.ts#L746-L782","documentation":"Thrown by importCodexAuthFromHome when the sourceHome argument trims to an empty string. addAccountFromHome expects a path to an already-authenticated CODEX_HOME to copy auth.json from; an empty/whitespace path is a caller bug, not an environment condition.","triggerScenarios":"Calling addAccountFromHome('') or addAccountFromHome('   ') (or passing an undefined-coerced string) from the 'orca account add --agent codex' CLI import path (service.ts:735).","commonSituations":"CLI argument not supplied (--agent codex without a home path), a form field left blank, or a caller passing `undefined` that was stringified.","solutions":["Validate and reject the empty sourceHome at the caller/CLI boundary before invoking addAccountFromHome.","Supply the actual CODEX_HOME directory that ran `codex login`.","If the user has no pre-authenticated home, use the interactive addAccount() flow instead of addAccountFromHome()."],"exampleFix":"// before\nservice.addAccountFromHome(input || '') // throws [908] when input empty\n\n// after: validate at the boundary\nif (!sourceHome?.trim()) { throw new Error('Pass the CODEX_HOME that ran `codex login`') }\nawait service.addAccountFromHome(sourceHome, target)","handlingStrategy":"validation","validationCode":"// Reject an empty source home before importing.\nif (!sourceHome || !sourceHome.trim()) {\n  throw new Error('A CODEX_HOME path is required for import.')\n}\nawait service.addAccountFromHome(sourceHome, target)","typeGuard":"const isNonEmptyHomePath = (value: string | undefined | null): value is string =>\n  typeof value === 'string' && value.trim().length > 0","tryCatchPattern":"try {\n  await service.addAccountFromHome(sourceHome, target)\n} catch (error) {\n  if (error instanceof Error && error.message === 'A Codex home directory path is required.') {\n    // prompt the user for the CODEX_HOME path\n  } else throw error\n}","preventionTips":["Validate non-empty inputs at the CLI/form boundary.","Default the import path to the directory the CLI logged into."],"tags":["codex-accounts","import","validation","caller-error"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}