[SERVER-27109] Shell: mongo port=XXXXX connects to default port but misleads user with message Created: 18/Nov/16  Updated: 06/Dec/22  Resolved: 03/Dec/21

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: 3.0.14, 3.2.10, 3.4.0-rc3
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Vick Mena (Inactive) Assignee: Backlog - Server Tooling and Methods (STM) (Inactive)
Resolution: Won't Fix Votes: 0
Labels: move-stm
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Server Tooling & Methods
Operating System: ALL
Steps To Reproduce:

mongod --dbpath . --logpath mongod.log --fork
mongo port=27018

Participants:

 Description   

The mongo shell connects to the default port when the connection string is incorrect and it prints a misleading message to the user leading them to believe they have connected correctly.

  • v3.0.14

    mongo port=27018
    MongoDB shell version: 3.0.14
    connecting to: port=27018
    

  • v3.2.10

    mongo port=27018
    MongoDB shell version: 3.2.10
    connecting to: port=27018
    

  • v3.4.0-rc3

    mongo port=27018
    MongoDB shell version v3.4.0-rc3
    connecting to: mongodb://127.0.0.1:27017/port=27018
    

The latest version is probably the least likely to be confusing but perhaps a failure to connect would be more educational to the user.



 Comments   
Comment by Brooke Miller [ 03/Dec/21 ]

We've deprecated the mongo shell in favor of the new mongosh. Unfortunately, we aren't able to pursue improvements to the deprecated shell except in extreme cases, such as critical security fixes. Please start making use of mongosh and let us know if it works for you in this case.

Comment by Matt Cotter [ 06/Dec/16 ]

For future reference, the solution here is to backport the work done to fix up the URI before printing it out to the v3.2 branch.

Comment by Vick Mena (Inactive) [ 28/Nov/16 ]

matt.cotter Fair point. Perhaps just cleanup the non URI "connecting to: ..." messages to help the user avoid confusion much like the cleaner URI message (e.g. "hostname:port/db")

Comment by Matt Cotter [ 28/Nov/16 ]

This is looks weird, but that's a valid database name.
Ex:

> use port=27018
switched to db port=27018
> db.test.insert({foo: 'bar'})
WriteResult({ "nInserted" : 1 })

then

$ mongo port=27018
MongoDB shell version v3.4.0-rc3
connecting to: mongodb://127.0.0.1:27017/port=27018
MongoDB server version: 3.4.0-rc3
> db.test.find()
{ "_id" : ObjectId("583c82f5e4a1d2efae9ddc5b"), "foo" : "bar" }

I think that the URI might make it clear what's happening. I agree that this is weird, but in my opinion there isn't anything to fix.

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