1 Commits
Author SHA1 Message Date
sneak 5fd9d8e07b Name each prefix once in restore, verify and purge errors (closes #327)
check / check (push) Canceled after 0s
A missing blob during restore, a failed shallow verify and an invalid
purge duration each printed their prefix twice. FetchBlob now returns
the storage error as is, since restore and deep verify name the blob
themselves; purge returns the duration parser's error unchanged; and a
failed shallow verify returns only what failed, because the command
prints "Verification failed:" before it. Deep verify words a storage
error other than not found as a blob it could not check, and its log
line no longer says S3.

Already fixed for
#314: the deep verify size
message naming S3 and other errors called missing; tests now check both.
Judgement call: the shallow verify error is a small error type, since
the linter refuses an error built from a plain string.
Not tested: the log line.

Model: opus-5-5
2026-10-13 23:11:16 +00:00
2 changed files with 9 additions and 6 deletions

No files matched your search

+1 -2
View File
@@ -100,8 +100,7 @@ func TestShallowVerifyDetectsWrongBlobSize(t *testing.T) {
// The cli layer prints this error after its own "Verification failed:".
err = newVerifier(io.Discard).VerifySnapshotWithOptions(
snapshotID, &vaultik.VerifyOptions{})
require.EqualError(t, err,
"problems found in storage: 1 blobs have the wrong size")
require.EqualError(t, err, "1 blobs have the wrong size")
}
// TestShallowVerifyDetectsMissingDatabase backs up a real snapshot,
+8 -4
View File
@@ -23,7 +23,6 @@ var (
errSnapshotNotInConfig = errors.New("snapshot not found in config")
errNoSnapshotsInConfig = errors.New("no snapshots configured")
errSnapshotVerifyFailed = errors.New("verification failed")
errProblemsInStorage = errors.New("problems found in storage")
errRemoveAllNeedsForce = errors.New("--all requires --force")
errSnapshotNotFound = errors.New("snapshot not found")
errSnapshotRemoveFailed = errors.New("snapshot(s) could not be removed")
@@ -908,6 +907,13 @@ func (v *Vaultik) verifyManifestBlobs(
return verified, missing, mismatched, missingSize, unchecked, nil
}
// shallowVerifyError is the error a failed shallow verify returns. Its
// text is only what failed, because the cli layer prints it after its own
// "Verification failed:".
type shallowVerifyError string
func (e shallowVerifyError) Error() string { return string(e) }
// formatVerifyResult outputs the final verification results as JSON or
// human-readable text.
func (v *Vaultik) formatVerifyResult(
@@ -942,10 +948,8 @@ func (v *Vaultik) formatVerifyResult(
v.printVerifySummary(result, failure)
}
// Not errSnapshotVerifyFailed: the cli layer prints this after its own
// "Verification failed:".
if failure != "" {
return fmt.Errorf("%w: %s", errProblemsInStorage, failure)
return shallowVerifyError(failure)
}
return nil