{"record":{"id":"f6cb66a4f63e9fab","repo":"chenhg5/cc-connect","slug":"codex-write-auth-json-w","errorCode":null,"errorMessage":"codex: write auth.json: %w","messagePattern":"codex: write auth\\.json: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/codex/provider_config.go","lineNumber":66,"sourceCode":"\thome, err := resolveCodexHomeForConfig(codexHome)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"codex: resolve codex home: %w\", err)\n\t}\n\tif err := os.MkdirAll(home, 0o755); err != nil {\n\t\treturn fmt.Errorf(\"codex: mkdir codex home: %w\", err)\n\t}\n\n\tauthPath := filepath.Join(home, \"auth.json\")\n\tpayload := map[string]any{\n\t\t\"OPENAI_API_KEY\": apiKey,\n\t\t\"auth_mode\":      \"apikey\",\n\t}\n\tdata, err := json.MarshalIndent(payload, \"\", \"  \")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"codex: marshal auth.json: %w\", err)\n\t}\n\tif err := os.WriteFile(authPath, append(data, '\\n'), 0o600); err != nil {\n\t\treturn fmt.Errorf(\"codex: write auth.json: %w\", err)\n\t}\n\tslog.Debug(\"codex: wrote auth.json\", \"path\", authPath)\n\treturn nil\n}\n\nfunc resolveCodexHomeForConfig(explicit string) (string, error) {\n\tif h := strings.TrimSpace(explicit); h != \"\" {\n\t\treturn h, nil\n\t}\n\tif h := strings.TrimSpace(os.Getenv(\"CODEX_HOME\")); h != \"\" {\n\t\treturn h, nil\n\t}\n\thomeDir, err := os.UserHomeDir()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn filepath.Join(homeDir, \".codex\"), nil\n}","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/codex/provider_config.go#L48-L84","documentation":"Wraps a failed os.WriteFile of the generated auth.json (mode 0600) under the resolved CODEX_HOME. It fires when the codex home directory is not writable — permissions, read-only filesystem, or a path occupied by a file where a directory is expected.","triggerScenarios":"Thrown at agent/codex/provider_config.go:66 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the codex home directory (default ~/.codex) is writable by cc-connect","Check disk space and read-only mounts","If CODEX_HOME is customized, verify the path exists and is a directory"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}