From d62831b1d501452954848fa54fc0eae98ac95d48 Mon Sep 17 00:00:00 2001 From: Felipe Gasper Date: Mon, 24 Mar 2025 12:34:26 -0400 Subject: [PATCH 1/2] save --- mongorestore/metadata.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mongorestore/metadata.go b/mongorestore/metadata.go index 02246db54..6b9cbed85 100644 --- a/mongorestore/metadata.go +++ b/mongorestore/metadata.go @@ -569,6 +569,10 @@ func (restore *MongoRestore) RestoreUsersOrRoles(users, roles *intents.Intent) e // present in the dump, we try to infer the authentication version based on its absence. // Returns the authentication version number and any errors that occur. func (restore *MongoRestore) GetDumpAuthVersion() (int, error) { + if restore.dumpServerVersion == db.Version{} { + panic("GetDumpAuthVersion() called with empty dump server version") + } + // authSchema doc has been removed from system.version from 8.1+ (SERVER-83663) // The only auth version used by server 8.1+ is 5 if restore.dumpServerVersion.GTE(db.Version{8, 1, 0}) { From bd304095604fd32d4b8c834547a0525d8561e9d2 Mon Sep 17 00:00:00 2001 From: Felipe Gasper Date: Mon, 24 Mar 2025 12:41:00 -0400 Subject: [PATCH 2/2] oops fix build --- mongorestore/metadata.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mongorestore/metadata.go b/mongorestore/metadata.go index 6b9cbed85..c8b77d4eb 100644 --- a/mongorestore/metadata.go +++ b/mongorestore/metadata.go @@ -17,6 +17,7 @@ import ( "github.com/mongodb/mongo-tools/common/intents" "github.com/mongodb/mongo-tools/common/log" "github.com/mongodb/mongo-tools/common/util" + "github.com/samber/lo" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" @@ -569,7 +570,10 @@ func (restore *MongoRestore) RestoreUsersOrRoles(users, roles *intents.Intent) e // present in the dump, we try to infer the authentication version based on its absence. // Returns the authentication version number and any errors that occur. func (restore *MongoRestore) GetDumpAuthVersion() (int, error) { - if restore.dumpServerVersion == db.Version{} { + if lo.EveryBy( + restore.dumpServerVersion[:], + func(v int) bool { return v == 0 }, + ) { panic("GetDumpAuthVersion() called with empty dump server version") }