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

MongoDB 3.6 URI does not parse into component parts correctly when the auth database and database being connected to are different

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.0.5
    • Affects Version/s: 3.0.2
    • Component/s: Core, Native

      The latest driver seems to have a problem with the case whereby the auth database and the database being connected to are different, or at least it seems to be a problem from 3rd party systems such as Mongoose when using the 3.6 URI syntax.

      The MongoDB Atlas, says that even on a v3.6 compliant driver I should use the /mytestdb syntax to set my database name even though I authenticate against the admin database as shown in the example below:

      mongodb+srv://test-user:3#f!69A8AZu9@cluster0-abcde.mongodb.net/mytestdb

      In the case of Mongoose they use the MongoDB driver library url_parser to parse the URL and get the DB name. In the latest version of the driver this seems to return 'admin'.

      If I use the 3.4 syntax as shown below it seems to work fine:

      mongodb://test-user:3#f!69A8AZu9@cluster0-shard-00-00-abcde.mongodb.net:27017,cluster0-shard-00-01-abcde.mongodb.net:27017,cluster0-shard-00-02-abcde.mongodb.net:27017/mytestdb?ssl=true&replicaSet=cluster0-shard-0&authSource=admin

      I am not sure if you would consider this a bug as it does not seem that the URL Parser is supposed to be a public API, but the url_parser does seem to have code that tries to set dbName to something other than its default of 'admin' in certain cases, and it works for the 3.4 syntax so I am assuming it is a bug.

            Assignee:
            matt.broadstone@mongodb.com Matt Broadstone
            Reporter:
            support@mybeat.net Bradley Greathead
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: