-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 4.1.6
-
Component/s: mongoimport
-
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