-
Type: Bug
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: None
What problem are you facing?
Trying to connect to mongodb+srv://username:password@somecluster/somedb?replicaSet=some-replica-set&connectTimeoutMS=10000&authMechanism=SCRAM-SHA-1&authSource=admin
The DBName is deleted because authSource in the URL exists, which results in the default dbName of the MongoClient to be set to "test". Removing authSource from the URL fixes the issue.
Apparently this was introduced in this commit: https://github.com/mongodb/node-mongodb-native/blob/ac445991a48b1c7b7a436a71fdad67c7b1cf9d4a/src/connection_string.tshttps://github.com/mongodb/node-mongodb-native/blob/main/src/connection_string.ts#L294
What driver and relevant dependency versions are you using?
4.2.0
Steps to reproduce?
const client = new MongoClient(mongoDbConnectionUri, this.options);
const db = client.db()
Any operations on db will always use 'test' as database name.
- depends on
-
NODE-3768 Investigate NODE-3767 - Default database name in URL is replaced by 'test' if authSource exists in connection string
- Closed
- duplicates
-
NODE-3775 Driver ignores in-uri provided database and uses test database
- Closed
- is related to
-
NODE-3779 MongoServerError: not authorized on test to execute command { createIndexes:
- Closed