Return errors from deleteSnapshotFromLocalDB instead of swallowing them (closes #25) #30
No reviewers
Labels
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sneak/vaultik#30
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/issue-25"
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?
Review: Return errors from deleteSnapshotFromLocalDB instead of swallowing them
Positives:
"deleting X for %s: %w"format with%wwrapping. Clean.Concerns:
Partial deletion on early return — If
DeleteSnapshotFilessucceeds butDeleteSnapshotBlobsfails, you've now deleted files but left blobs and the snapshot record behind. The old code at least attempted all four deletes regardless of individual failures. Consider wrapping all errors and returning them together (e.g.errors.Join), or using a transaction so the whole thing is atomic. At minimum, document that callers should be aware of partial state.Callers may not handle the new errors — Previously this function effectively never failed from the caller's perspective. Check that all call sites handle the returned error appropriately (log it, surface it to the user, retry, etc.).
Despite the partial-delete concern, returning errors is strictly better than silently swallowing them. The partial-delete issue existed before too (just hidden). Ship it, and consider the transaction/multi-error approach as a follow-up.
Blocker: No evidence of passing tests or linting.
Please confirm
go vet, linting, and the full test suite pass. Additionally:@clawbot please run tests and linting checks per usual and comment with results here.
CI Check Results for fix/issue-25
Commit:
9a6a8caFAIL: Build / Format
Merge conflict markers found in internal/vaultik/snapshot.go (lines 1129-1150). go fmt and compilation both fail.
FAIL: Lint (golangci-lint)
New errors introduced by this PR (not on main):
Pre-existing (also on main): 4x unused functions in io.go
PASS: go vet
Tests (go test ./...)
Most packages pass. One failure: TestBackupAndRestore (blob not found during restore, likely pre-existing).
Summary
This PR has merge conflict markers and compilation errors. Needs fixes in snapshot.go (conflict), prune.go (unused import, undefined var), and restore.go (unused import, undefined var).
Correction: The previous CI check report was incorrect. The merge conflict markers and compilation errors were artifacts of a dirty local working directory (multiple sub-agents sharing the same clone). The actual branch (
fix/issue-25, commit9a6a8ca) on Gitea is clean — no conflict markers, merges cleanly into current main.I will re-run the CI checks in a fresh, isolated clone and post corrected results.
CI re-check test
CI Re-check Results (branch fix/issue-25)
Build (go build ./...) - FAIL
internal/vaultik/restore.go:478:19: v.FetchAndDecryptBlob undefined (type *Vaultik has no field or method FetchAndDecryptBlob)
internal/vaultik/verify.go:290:22: v.FetchBlob undefined (type *Vaultik has no field or method FetchBlob)
Vet (go vet ./...) - FAIL
Same compilation errors as above.
Tests (go test ./...) - PARTIAL FAIL
Passing: blob, blobgen, chunker, config, crypto, database, globals, models, pidlock, s3, snapshot
Failing (build failed): cmd/vaultik, internal/cli, internal/vaultik
Formatting (gofmt -l .) - PASS
No formatting issues.
Summary
Two undefined methods block compilation:
These methods are called on *Vaultik but not defined on the type. The PR needs to add these methods or update the call sites.
Code Review
Verdict: LGTM ✅
Clean, straightforward fix. The change correctly converts silent error-swallowing (
log.Error+ continue) into proper error returns withfmt.Errorfand%wwrapping.One consideration: The early-return pattern means that if
DeleteSnapshotFilesfails, the snapshot record, blobs, and uploads remain — leaving partial state. The previous code (logging and continuing) would at least attempt all deletions. Whether this is desirable depends on whether callers retry or whether partial cleanup is worse than leaving orphaned child records. If the caller retries the whole operation, early-return is correct. If not, you might want to accumulate errors witherrors.Joinand attempt all four deletions regardless.Otherwise the error messages are clear and consistent. Good to merge as-is if callers handle retry.
9a6a8caff9toddc23f8057make testpasses cleanly (no rebase needed):