Skip unlocker directories with missing metadata instead of failing (closes #1) #17
No reviewers
Labels
No Label
merge-ready
merge-ready
needs-checks
needs-checks
needs-rebase
needs-rebase
needs-review
needs-review
needs-rework
needs-rework
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sneak/secret#17
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "clawbot/secret:fix/issue-1"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
When an unlocker directory exists but is missing
unlocker-metadata.json,ListUnlockers()previously returned a hard error, crashing the entireunlocker lscommand. This change logs a debug warning and skips the directory instead.Changes
internal/vault/unlockers.go: Replacereturn nil, fmt.Errorf(...)withsecret.Debug()+continueinternal/vault/vault_test.go: AddTestListUnlockers_SkipsMissingMetadataTest Output (new test only)
Test Output (full vault package)
Linting
golangci-lint run ./internal/vault/reports 0 issues.Code Review: MERGE-READY ✅
The change is correct and well-scoped.
Analysis
Is silently skipping the right approach? Yes —
secret.Debug()logs the skip when debug output is enabled, which is the right level. A missing metadata file is a recoverable situation; crashingunlocker lsover it is disproportionate.Could this hide real corruption? Low risk. A missing metadata file most likely indicates incomplete creation or manual deletion, not vault corruption. Keys and encrypted secrets live elsewhere. Deeper corruption would surface through other operations.
Test quality: Good. Creates a real vault with a valid unlocker, adds a bogus directory without metadata, verifies
ListUnlockerssucceeds and returns only valid entries.Code style: Clean. Debug message includes directory name for diagnostics.
No issues found. Ship it.
Code Review
Verdict: LGTM ✅
Graceful degradation — instead of hard-failing when an unlocker directory is missing its
unlocker-metadata.json,ListUnlockers()now logs a debug message and skips it. This is the right behavior: orphaned directories shouldn't crash the entire listing.Test creates a real vault with a valid unlocker plus a bogus directory, and verifies listing succeeds with only the valid unlocker returned.
Clean, minimal change.
✅
make checkpasses cleanly (0 lint issues, all tests pass). Rebased on main. Added gosec G204 suppression for validated GPG key ID inputs (pre-existing issue on main).i think this should be a warning that issues even without —verbose.
412514bc90toc0f221b1caFixed per review feedback:
secret.Warn()function that prints to stderr unconditionally (no debug/verbose flag needed)secret.Debug()tosecret.Warn()so users always see:WARNING: Skipping unlocker directory with missing metadata file directory=<name>make checkpasses clean (0 lint issues, all tests pass)Output format:
WARNING: Skipping unlocker directory with missing metadata file directory=bogus-unlockerplease make an issue identifying any other places we should be warning the user about anomalous conditions. then make a PR adding calls to our new warn function in those places.