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

Connection string containing @ mark throws MongoAPIError

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • Not Needed

      What problem are you facing?

      The issue is with the connection string password. If the password contatins @ mark the exception is thrown:

      MongoAPIError: URI must include hostname, domain name, and tld
      at Object.resolveSRVRecord (/home/endrju/UrlManagementSystem/node_modules/mongodb/lib/connection_string.js:51:25)
      at Object.connect (/home/endrju/UrlManagementSystem/node_modules/mongodb/lib/operations/connect.js:41:36)
      at /home/endrju/UrlManagementSystem/node_modules/mongodb/lib/mongo_client.js:127:23
      at Object.maybePromise (/home/endrju/UrlManagementSystem/node_modules/mongodb/lib/utils.js:518:5)
      at MongoClient.connect (/home/endrju/UrlManagementSystem/node_modules/mongodb/lib/mongo_client.js:126:24)
      at Object.<anonymous> (/home/endrju/UrlManagementSystem/main.js:4:8)
      at Module._compile (node:internal/modules/cjs/loader:1108:14)
      at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
      at Module.load (node:internal/modules/cjs/loader:988:32)
      at Function.Module._load (node:internal/modules/cjs/loader:828:14)
      /home/endrju/UrlManagementSystem/node_modules/mongodb/lib/utils.js:526
      throw error;

       

      What driver and relevant dependency versions are you using?

      mongodb":"^4.1.1"

      node v16.0.0

      OS: Linux 5.9.16-1-MANJARO

      Steps to reproduce?

      1. Set a password for a database user https://cloud.mongodb.com/  containing @ mark.

      password: passwordwith@mark

      connection string:

      mongodb+srv://user_31:passwordwith@mark@cluster0.xuvw0.mongodb.net/sample_airbnb?retryWrites=true&w=majority

      2. Create the instance of MongoClient

      3. Call connect method.

      4. Do the console.log to print the error.

       

       

       

       

       

       

       

            Assignee:
            kaitlin.mahar@mongodb.com Kaitlin Mahar
            Reporter:
            andrzej.mikulec.pl@gmail.com Andrzej Mikulec
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: