{"record":{"id":"fe35e5598bedc1ae","repo":"chenhg5/cc-connect","slug":"codex-marshal-auth-json-w","errorCode":null,"errorMessage":"codex: marshal auth.json: %w","messagePattern":"codex: marshal auth\\.json: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/codex/provider_config.go","lineNumber":63,"sourceCode":"\tif apiKey == \"\" {\n\t\treturn nil\n\t}\n\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","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/codex/provider_config.go#L45-L81","documentation":"Wraps a json.MarshalIndent failure while building the codex auth.json payload inside ensureCodexAuth. The payload is a trivial fixed-shape map, so this is effectively unreachable in practice; it would only fire on a non-serializable value type creeping into the payload.","triggerScenarios":"Thrown at agent/codex/provider_config.go:63 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Treat as a programming bug — report it upstream","No user-facing remediation; the payload shape is static"],"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-14T00:17:10.932Z"}