test(config): cover Save/Load faults + clearAll (token-persistence integrity)#254
Merged
Conversation
…tegrity) The config-fault harness from the coverage audit — no production changes, root-proof fault injection (parent-is-a-file, path-is-a-directory, non-empty-dir) plus one chmod case guarded by a non-root euid: - Load (74%): corrupt JSON -> parse error; an unreadable path (a directory) -> read error. A garbled/unreadable config must error, never silently read as "not signed in". - Save (~65%): un-creatable dir (parent is a file) -> error; read-only dir -> temp-file creation error (the atomic-write fault, the most safety-relevant path); fully-empty profiles are pruned (and stay off disk on reload). - clearAll (67%): removes an existing config; missing file is a no-op; a non-empty dir at the path surfaces a remove error. make ci green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Author
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 633310c. Configure here.
saadqbal
approved these changes
Jul 14, 2026
saadqbal
left a comment
Collaborator
There was a problem hiding this comment.
LGTM 👍 Good fault coverage on the token-persistence path — the atomic-write failure arms and the empty-profile prune round-trip are the ones that matter, and the error wording (parsing/reading/creating) matches. Sensible root/euid skips.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The config-fault harness from the coverage audit — no production changes, root-proof fault injection (parent-is-a-file, path-is-a-directory, non-empty-dir) + one chmod case guarded by a non-root euid.
make cigreen.🤖 Generated with Claude Code
Note
Low Risk
Test-only coverage expansion for existing config behavior; no runtime or security logic changes.
Overview
Adds
internal/config/fault_test.goonly—no production code changes. Tests drive config I/O throughTRACEBLOC_CONFIG_DIRand fault injection (corrupt JSON, path-as-directory, parent-is-a-file, read-only dir with a non-root skip, non-empty dir at the config path).Load: corrupt JSON must return a parse error; whenconfig.jsonis a directory, a read error—so the CLI never treats a broken file as “not signed in.”Save: un-creatable config dir and read-only dir must fail (atomic write must not silently truncate tokens); fully empty profiles are pruned in memory and stay absent after reload.clearAll: removes an existing file, no-ops when missing, and errors when the path is a non-empty directory.Reviewed by Cursor Bugbot for commit 633310c. Bugbot is set up for automated code reviews on this repo. Configure here.