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

Default database name in URL is replaced by 'test' if authSource exists in connection string

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 4.2.1
    • Affects Version/s: None
    • Component/s: None
    • 2
    • Not Needed

      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:
            daria.pardue@mongodb.com Daria Pardue
            Reporter:
            pbug90@protonmail.com Patrick Bug
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: