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

mongoimport --uri logs incorrect connected hosts

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.0.7, 4.1.11
    • Affects Version/s: 4.1.6
    • Component/s: mongoimport
    • Labels:
    • v4.0

      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

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

              Created:
              Updated:
              Resolved: