chenhg5/cc-connect · error
codex: marshal auth.json: %w
Error message
codex: marshal auth.json: %w
What it means
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.
Source
Thrown at agent/codex/provider_config.go:63
if apiKey == "" {
return nil
}
home, err := resolveCodexHomeForConfig(codexHome)
if err != nil {
return fmt.Errorf("codex: resolve codex home: %w", err)
}
if err := os.MkdirAll(home, 0o755); err != nil {
return fmt.Errorf("codex: mkdir codex home: %w", err)
}
authPath := filepath.Join(home, "auth.json")
payload := map[string]any{
"OPENAI_API_KEY": apiKey,
"auth_mode": "apikey",
}
data, err := json.MarshalIndent(payload, "", " ")
if err != nil {
return fmt.Errorf("codex: marshal auth.json: %w", err)
}
if err := os.WriteFile(authPath, append(data, '\n'), 0o600); err != nil {
return fmt.Errorf("codex: write auth.json: %w", err)
}
slog.Debug("codex: wrote auth.json", "path", authPath)
return nil
}
func resolveCodexHomeForConfig(explicit string) (string, error) {
if h := strings.TrimSpace(explicit); h != "" {
return h, nil
}
if h := strings.TrimSpace(os.Getenv("CODEX_HOME")); h != "" {
return h, nil
}
homeDir, err := os.UserHomeDir()
if err != nil {
return "", errView on GitHub (pinned to 4000b2338a)
Solutions
- Treat as a programming bug — report it upstream
- No user-facing remediation; the payload shape is static
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at agent/codex/provider_config.go:63 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/fe35e5598bedc1ae.
Report an issue: GitHub.