Skip to content

test(config): cover Save/Load faults + clearAll (token-persistence integrity)#254

Merged
saadqbal merged 1 commit into
developfrom
test/config-fault
Jul 14, 2026
Merged

test(config): cover Save/Load faults + clearAll (token-persistence integrity)#254
saadqbal merged 1 commit into
developfrom
test/config-fault

Conversation

@LukasWodka

@LukasWodka LukasWodka commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

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.

  • Load (74%): corrupt JSON → parse error; an unreadable path (a directory) → read error.
  • Save (~65%): un-creatable dir → 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 existing; missing is a no-op; a non-empty dir at the path surfaces a remove error.

make ci green.

🤖 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.go only—no production code changes. Tests drive config I/O through TRACEBLOC_CONFIG_DIR and 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; when config.json is 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.

…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>
@LukasWodka

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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.

@LukasWodka LukasWodka self-assigned this Jul 14, 2026

@saadqbal saadqbal left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@saadqbal
saadqbal merged commit 68c2bd8 into develop Jul 14, 2026
22 checks passed
@saadqbal
saadqbal deleted the test/config-fault branch July 14, 2026 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants