fix: Report the real reason verify falls back to archive-only checks

resolveGlobals can fail for two distinct reasons — no MongoDB URI, or no
resolvable database name — and verify.go was printing a hardcoded
no-URI note regardless of which one occurred, misleading an operator
whose URI was fine but whose database name could not be resolved.
This commit is contained in:
2026-09-07 14:11:58 +00:00
parent e08cc2f928
commit 884fd189fb
+5 -5
View File
@@ -33,9 +33,9 @@ func newVerifyCmd() *cobra.Command {
opt := backup.VerifyOptions{Archive: archive}
// A database is optional here. resolveGlobals fails without a URI,
// so its error is a signal to verify the archive alone rather than
// a reason to stop.
// A database is optional here. resolveGlobals fails without a URI or
// without a resolvable database name, and either error is a signal to
// verify the archive alone rather than a reason to stop.
var client *mongo.Client
if g, gerr := resolveGlobals(c); gerr == nil {
client, err = connect(ctx, g)
@@ -47,8 +47,8 @@ func newVerifyCmd() *cobra.Command {
opt.Database = g.Database
opt.KeyHex = g.KeyHex
} else {
fmt.Fprintln(c.ErrOrStderr(),
"note: no MongoDB URI, so this checks the archive and the key only")
fmt.Fprintf(c.ErrOrStderr(),
"note: %v, so this checks the archive and the key only\n", gerr)
}
rep, err := backup.Verify(ctx, opt)