Skip to content

[Bug]: Malformed config gets silently overwritten on startup #344

@ben-ranford

Description

@ben-ranford

Bug Description

Malformed configuration files are silently overwritten during startup paths. If ~/.ggcconfig.yaml contains invalid YAML, ggc logs a parse error but then rewrites the file with generated defaults.

Steps to Reproduce

  1. Create a malformed config file:
    MOD=$(go env GOMODCACHE); CCH=$(go env GOCACHE); TMP=$(mktemp -d)
    printf 'broken: [yaml\n' > "$TMP/.ggcconfig.yaml"
  2. Run ggc with that HOME:
    HOME="$TMP" GOMODCACHE="$MOD" GOCACHE="$CCH" go run . version >/dev/null 2>/tmp/err.txt
  3. Inspect stderr and config file:
    head -n1 /tmp/err.txt
    sed -n '1,6p' "$TMP/.ggcconfig.yaml"

Expected Behavior

If config parsing fails, ggc should report the error and leave the existing config file untouched.

Screenshots

N/A

Environment

  • OS: macOS 26.2
  • Go Version: go version go1.25.7 darwin/arm64
  • ggc Version: ggc version v1.0.0 (commit: abc123)
  • git Version (run git --version): git version 2.39.5 (Apple Git-154)

Additional Context

Root cause was two startup write paths after parse failure:

  1. pkg/config.Manager.LoadConfig() always called Save().
  2. cmd/version proceeded with metadata updates that call Set() (which persists config).

closes #343

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions