1 Commits
Author SHA1 Message Date
sneak 2b61947eb0 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 wraps "problems found in storage" instead of
"verification failed", which the command already prints. 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.
Not tested: the log line.

Model: opus-5-5
2026-10-13 23:31:29 +00:00
2 changed files with 6 additions and 9 deletions
+2 -1
View File
@@ -100,7 +100,8 @@ 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, "1 blobs have the wrong size")
require.EqualError(t, err,
"problems found in storage: 1 blobs have the wrong size")
}
// TestShallowVerifyDetectsMissingDatabase backs up a real snapshot,
+4 -8
View File
@@ -23,6 +23,7 @@ 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")
@@ -907,13 +908,6 @@ 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(
@@ -948,8 +942,10 @@ func (v *Vaultik) formatVerifyResult(
v.printVerifySummary(result, failure)
}
// Not errSnapshotVerifyFailed: the cli layer prints this after its own
// "Verification failed:".
if failure != "" {
return shallowVerifyError(failure)
return fmt.Errorf("%w: %s", errProblemsInStorage, failure)
}
return nil