Uploaded image for project: 'MongoDB CLI Tools'
  1. MongoDB CLI Tools
  2. TOOLS-2166

mongoimport --uri logs incorrect connected hosts

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 4.1.6
    • Fix Version/s: 4.0.7, 4.1.11
    • Component/s: mongoimport
    • Labels:

      Description

      mongoimport outputs incorrect connected host when -uri is used instead of --host. For example, when -host is used as below:

      mongoimport --host "replicasetName/host1:27017,host2:27017,host3:27017" --ssl -u username -p password --authenticationDatabase admin --db dbname --collection collname --file foobar.json 
      

      It outputs correctly the replica set it connects to:

      2018-12-05T23:19:14.752+1100	connected to: replicasetName/host1:27017,host2:27017,host3:27017
      

      However, when --uri is used:

      mongoimport --uri "mongodb://username:password@host1,host2,host3/dbName?ssl=true&replicaSet=replicasetName?&authSource=admin" --collection collname --file foobar.json
      

      It outputs "localhost" as the default value of cluster:

      2018-12-05T23:29:00.429+1100	connected to: localhost
      

      Similarly when the value of the --uri parameter is mongodb+srv format.  

      This is due to the default value assignment in https://github.com/mongodb/mongo-tools/blob/r4.1.6/mongoimport/mongoimport.go#L348-L351

        Attachments

          Activity

            People

            • Assignee:
              david.golden David Golden
              Reporter:
              wan.bachtiar Wan Bachtiar
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: