Repository navigation
fix(cli): warn when the stored client config cannot be read - #312
KrasimirKralev wants to merge 1 commit into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR warns on stderr when stored client configuration cannot be read or parsed and includes the file path in JSON parse errors. Example: After login to http://127.0.0.1:18432, config.json is truncated and the user runs clickclack whoami.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: current main still silently discards config-read errors, and this focused diagnostic fix has no actionable findings. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe CLI loads saved server and credential defaults before dispatching client commands; configuration errors now produce stderr diagnostics while existing option precedence and HTTP requests remain unchanged. flowchart TD
A[CLI arguments and environment] --> B[Client defaults]
C[Stored config file] --> D[Config loader]
D --> B
D --> E[Stderr warning on read or parse failure]
B --> F[Client command]
F --> G[HTTP API]
Technical reviewBest possible solution: Land the focused warning and path-aware parse error while preserving existing fallback and credential-storage behavior. Do we have a high-confidence way to reproduce the issue? Current-main source demonstrably drops non-missing-file loading errors, and the contributor supplies matching before/after CLI traces; no target code was executed during this review. Is this the best way to solve the issue? The existing shared loader is the appropriate owner, and the patch adds the missing diagnostic without introducing another configuration path or changing fallback semantics. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against fb9b9314bdfe. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 2, 2026, 5:28 AM ET / 10:28 UTC. |
What Problem This Solves
When the stored client config file is damaged or unreadable, every client command silently ignores it and talks to
http://localhost:8080with no token, so a logged-in user seesconnection refused(or a bare 401 from a local server) with nothing pointing at the file.defaultClientOptions()(apps/api/cmd/clickclack/client.go:108) drops everyloadClientConfig()error, not only "file does not exist". A truncatedconfig.json(interrupted editor save, full disk) or one the user cannot read looks exactly like "never logged in".--jsonoutput, and the missing-file case (still silent). No config format or path change;login/logoutbehave as before.User Impact
A user whose config is damaged now gets one stderr line naming the file, the parse or open error, and the way out (
clickclack loginor delete the file), instead of a network error about a server they never configured.Why This Change Was Made
defaultClientOptions()prints a one-line stderr warning whenloadClientConfig()fails with anything other thanos.ErrNotExist;loadClientConfig()wraps JSON errors with the file path (read errors fromos.ReadFilealready carry it). One## UnreleasedCHANGELOG line.if err == nil { … }with no else branch treated every error as "no config".client_config_test.go: a truncated config must produce the warning naming the path and keep the built-in default server; a missing config and a valid config must stay quiet. With theclient.gochange reverted the truncated-config case fails and the two quiet cases still pass;gofmt,go vet ./cmd/clickclackandgo test ./...inapps/apipass.Evidence
clickclack whoamiprints after a successfulloginwhen the storedconfig.jsonis then truncated.go build ./cmd/clickclackofupstream/main(fb9b931) and of this branch (36337e1); a scratchclickclack serve --dev-bootstrapon 127.0.0.1:18432 with a magic link fromclickclack admin magic-link create;HOMEandXDG_CONFIG_HOMEunder a scratch dir.clickclack login --server http://127.0.0.1:18432 --magic-token mgt_…,clickclack whoami,truncate -s 40on the stored config, thenclickclack whoamiwith each binary; plus a mode-000 config and the no-config / valid-config controls.clickclackbinary, a truncated or unreadable config now prints one stderr line with the path, the error and the fix; the request and exit code are unchanged. Without a config file, and with a valid one, the output is identical on both binaries.os.UserConfigDir(), unchanged here).