Skip to content

fix(config): treat blank config files as absent - #4081

Closed
steipete wants to merge 2 commits into
mainfrom
triage/20260921-config-empty
Closed

steipete wants to merge 2 commits into
mainfrom
triage/20260921-config-empty

Conversation

@steipete

@steipete steipete commented Sep 28, 2026 •

Copy link
Copy Markdown
Owner

Blank config files currently stop CLI usage with a decode error even though a missing file works. The shared config store now treats zero bytes and JSON whitespace as absent, so the existing default-backed paths work on macOS and Linux. Non-empty input still uses the existing decoder and error handling; config paths and credential storage are unchanged.

Regression coverage checks missing, empty, whitespace-only, and malformed files; read-only byte preservation; default creation and private settings saves; retained in-memory app settings; and CLI usage through an isolated local RPC stub. The configuration docs and 0.68.1 changelog describe the behavior.

Verification:

  • swift build -j 2 --product CodexBarCLI — passed (Build complete! (686.93 sec)).
  • Isolated CodexBarCLI config validate --json — missing/empty/whitespace exit 0 without writing; malformed JSON exits 1 with kind: config. The same empty-file expectation failed on the baseline CLI with exit 1 before the fix.
  • Isolated CodexBarCLI usage --provider codex --source cli --json --json-only using a local synthetic RPC executable — returned the expected 1% usage for missing, empty, and whitespace files, leaving each file unchanged.
  • Isolated CodexBarCLI config enable --provider grok --json — subsequent saves produced valid JSON with 0600 permissions for all three absence cases; malformed input remained unchanged and exited 1.
  • make check — passed; SwiftLint reported 0 violations across 2,671 files.
  • Independent review through P2 — no actionable findings in the final staged change.
  • Initial CI attempt at 05f37ae903a1: both macOS test shards passed, and the Linux config-store suite passed all 11 parameter cases (3 tests). Lint and the musl build passed. Linux x64 ran 850 tests and failed only an unrelated Abacus timing assertion: 9.003251 seconds against a strict 9-second limit. The failed-job rerun (attempt 2) passed at the same head without code changes; CI run.
  • The local focused Swift run was stopped during compilation after prolonged shared-host contention and low disk space; no local unit-test results are claimed. This worktree's build directory was removed. The CI macOS/Linux runs supply the Swift-test validation.

The attempted local focused command was:

source Scripts/test_environment.sh
swift test -j 2 --filter 'CodexBarConfigStoreEmptyTests|SettingsStoreEmptyConfigTests|CLIPluginConfigPreservationTests|PluginConfigPreservationLinuxTests|CodexBarConfigUnknownProviderTests|CodexBarConfigHooksTests|ConfigValidationTests|CredentialFileWriterTests|CLIConfigCommandTests|ProviderConfigByteStabilityTests'

Production delta against the branch base: 1 file changed, 2 insertions(+), 2 deletions(-), net 0.

Fixes #4071

@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed September 27, 2026, 10:53 PM ET / September 28, 2026, 02:53 UTC (Revision 3).

ClawSweeper review

What this changes

The branch makes the shared config reader treat empty or JSON-whitespace-only files as absent, with tests and documentation for CLI usage, app settings, and later saves.

Merge readiness

✅ Ready for maintainer review

Keep open: the linked failure remains on current main, and this PR is a focused, well-supported candidate fix. I found no actionable introduced defect.

Priority: P2
Reviewed head: 05f37ae903a149602bd9ce9b4542e52a279aa95b

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A narrow patch has focused cross-platform coverage and reported before-and-after CLI behavior, with no blocking defect found.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The changed config loader feeds CLI validation and usage; the PR body reports isolated after-fix CLI runs with blank files, a local RPC stub, preserved read-only bytes, and a subsequent valid save, alongside a baseline failure. Existing blank-file upgrade behavior and malformed-file preservation are exercised; the serialized JSON shape is unchanged.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The changed config loader feeds CLI validation and usage; the PR body reports isolated after-fix CLI runs with blank files, a local RPC stub, preserved read-only bytes, and a subsequent valid save, alongside a baseline failure. Existing blank-file upgrade behavior and malformed-file preservation are exercised; the serialized JSON shape is unchanged.
Evidence reviewed 10 items Current main still fails on blank files: The current main loader decodes every existing file; it has no empty-file or whitespace guard.
Introduced repair: The PR's introduced hunk returns nil for zero bytes and the four JSON whitespace bytes before decoding; other input still uses the existing decoder and error wrapper.
CLI behavior boundary: CLI config validation and provider edits use the shared config loader; usage also loads config before obtaining provider data.
Findings None None.
Security None None.

How this fits together

The shared config store reads config.json for both the macOS menu bar app and the CLI. Its result supplies provider settings and usage commands; settings edits write JSON back to the file.

flowchart LR
A[Config file] --> B[Shared config reader]
B --> C{Blank or missing?}
C -->|Yes| D[Default configuration]
C -->|No| E[Decode JSON]
D --> F[App settings]
D --> G[CLI usage and edits]
E --> F
E --> G
E -->|Invalid| H[Config error]
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Code and test delta production +2/-2 lines; tests +169/-1 lines The behavior change is small and has focused coverage without net production growth.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #4071
Summary: This PR explicitly targets the blank-config failure reported in the linked open issue.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Land the shared-loader repair with the stated blank-file save policy and keep the malformed-file guard; resolve the linked issue after merge.

Do we have a high-confidence way to reproduce the issue?

Yes. Current main decodes every existing blank file, and the linked report supplies isolated Linux CLI steps; this read-only review did not execute them.

Is this the best way to solve the issue?

Yes. One guard in the shared loader repairs the app and CLI paths while the existing decoder continues to reject malformed non-empty files.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against cda264c299ad.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: A blank config blocks usage for an affected installation, but the failure is limited to this file state.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The changed config loader feeds CLI validation and usage; the PR body reports isolated after-fix CLI runs with blank files, a local RPC stub, preserved read-only bytes, and a subsequent valid save, alongside a baseline failure. Existing blank-file upgrade behavior and malformed-file preservation are exercised; the serialized JSON shape is unchanged.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed config loader feeds CLI validation and usage; the PR body reports isolated after-fix CLI runs with blank files, a local RPC stub, preserved read-only bytes, and a subsequent valid save, alongside a baseline failure. Existing blank-file upgrade behavior and malformed-file preservation are exercised; the serialized JSON shape is unchanged.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • kiranmagic7: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-28T01:21:57.442Z sha 05f37ae :: blocked before merge. :: none
  • reviewed 2026-09-28T02:36:45.614Z sha 05f37ae :: needs maintainer review before merge. :: none

steipete added a commit that referenced this pull request Sep 28, 2026
A zero-byte or whitespace-only config file now behaves like a missing one (defaults, usage keeps working, next save writes valid JSON with 0600 permissions) instead of failing closed and blanking usage; malformed non-empty JSON keeps its decode error and protected writes. Fixes #4071.

Thanks @kvnloo!
@steipete

Copy link
Copy Markdown
Owner Author

Landed on main as 610c391 via merge train #4096 (one green CI run for the whole train).

@steipete steipete closed this Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Empty config.json fails closed and blanks usage; a missing file does not

1 participant