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

Query parameters with path in connection string not working on windows

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 3.6.3
    • 4.0.0, 3.6.4
    • Shell
    • None

    Description

      Problem Description

      Some of the query parameters in a connection string allow a file path to be specified, e.g. the tlsCAFile option, that will be resolved to the file contents before connecting. However, using an absolute path on Windows will result in an error:

      TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received an instance of Object

      It seems that the error is caused by the parseQueryStringItemValue method (https://github.com/mongodb/node-mongodb-native/blob/master/src/connection_string.ts#L154). It checks for the presence of a : in the parameter value and if so converts it into an object with key-values by splitting. However, an absolute path on windows will always start with <drive letter>:\... so the : will always be present.

      This at least affects v4 - not tested for 3.x.

      Steps to Reproduce

      Try connecting to a MongoDB node passing the tlsCAFile query parameter in the connection string on Windows with a valid absolute path.

      Expected Results

      The connection is created and works/fails according to the CA provided.

      Actual Results

      No connection is created but an error is thrown while trying to execute fs.readFileSync when resolving the tlsCAFile.

      Attachments

        Issue Links

          Activity

            People

              eric.adum@mongodb.com Eric Adum (Inactive)
              michael.rose@mongodb.com Michael Rose (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: