[SERVER-33059] Shell no longer accepts legacy connection strings Created: 01/Feb/18  Updated: 28/Feb/18  Resolved: 02/Feb/18

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: 3.4.11
Fix Version/s: None

Type: Bug Priority: Critical - P2
Reporter: Kevin Arhelger Assignee: Sara Golemon
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-31437 Fix parsing of `mongo host/db` connec... Closed
Related
related to SERVER-29921 Mongo connection uri doesn't support ... Closed
Operating System: ALL
Participants:
Case:

 Description   

The MongoDB 3.4.11 shell broke the "legacy" style host[:port]/dbname connection string format.

3.4.11

$ mongo localhost/admin
MongoDB shell version v3.4.11
connecting to: mongodb://admin:27017/localhost
2018-02-01T14:16:28.467-0600 I NETWORK  [thread1] getaddrinfo("admin") failed: nodename nor servname provided, or not known
2018-02-01T14:16:28.467-0600 E QUERY    [thread1] Error: couldn't initialize connection to host admin, address is invalid :
connect@src/mongo/shell/mongo.js:240:13
@(connect):1:6
exception: connect failed

There are two workarounds for this issue:

  • Use a 3.4.10 shell:

    $ mongo localhost/admin
    MongoDB shell version v3.4.10
    connecting to: mongodb://localhost/admin
    MongoDB server version: 3.4.11
    >
    

  • Use the --host <host> <database> syntax:

    $ mongo --host localhost admin
    MongoDB shell version v3.4.11
    connecting to: mongodb://localhost:27017/admin
    MongoDB server version: 3.4.11
    >
    

The documentation and --help parameters both show this as a valid connection string.

mongo --help
MongoDB shell version v3.4.11
usage: mongo [options] [db address] [file names (ending in .js)]
db address can be:
  foo                   foo database on local machine
  192.168.0.5/foo       foo database on 192.168.0.5 machine



 Comments   
Comment by Ramon Fernandez Marina [ 02/Feb/18 ]

I'm marking this as a duplicate of SERVER-31437, since the fix is actually a 3.4 backport of the fix in that ticket.

Comment by Sara Golemon [ 02/Feb/18 ]

Fix backported for 3.4.12
Sorry this got missed!
https://github.com/mongodb/mongo/commit/88e8afb9f01b7e8322537eaab2a30e2834b04eaa

Comment by Ramon Fernandez Marina [ 01/Feb/18 ]

Thanks for the quick analysis sara.golemon – backport approved.

Comment by Sara Golemon [ 01/Feb/18 ]

This was fixed for 3.6 by SERVER-31437, but when SERVER-29921 was backported to 3.4, we didn't backport the fix as well. I've requested a backport for 31437, and we should have the fix in place in time for 3.4.12.

Generated at Thu Feb 08 04:32:09 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.