Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-3768

Investigate NODE-3767 - Default database name in URL is replaced by 'test' if authSource exists in connection string

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • 1
    • Not Needed

      NODE-3767 Description

      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.

       

       

            Assignee:
            durran.jordan@mongodb.com Durran Jordan
            Reporter:
            dbeng-pm-bot PM Bot
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: