[SERVER-38338] Add default "mongo" shell helper method to inform user of error Created: 30/Nov/18  Updated: 06/Dec/22  Resolved: 17/Dec/20

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

Type: Improvement Priority: Minor - P4
Reporter: Nathan Leniz 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

Issue Links:
Related
related to SERVER-21493 Double quotes in shellHelper args are... Closed
related to SERVER-17162 Give nice error if you run mongoimpor... Closed
Assigned Teams:
Server Tooling & Methods
Sprint: Dev Tools 2018-12-17, Dev Tools 2018-12-31, Dev Tools 2019-01-14, Dev Tools 2019-01-28, Dev Tools 2019-02-11
Participants:

 Description   

Currently, new users who may not be very familiar with a shell environment can easily find themselves in a mongo shell, such as verifying they've correctly added it to their path. Then, they may not exit the mongo shell but instead try to launch a new shell or connect to a database. This results in the following errors.

MongoDB Enterprise > mongo
2018-11-30T13:42:15.701-0500 E QUERY [js] ReferenceError: mongo is not defined :
@(shell):1:1
MongoDB Enterprise > mongo localhost
2018-11-30T13:45:37.703-0500 E QUERY    [js] SyntaxError: missing ; before statement @(shell):1:6

There are currently 22 threads in Education's new forums that show users encountering this situation, and countless more in our old forums. Adding a default to shellHelper would help ameliorate this and provide better feedback to our newer users.



 Comments   
Comment by Robert Guo (Inactive) [ 17/Dec/20 ]

We are deprecating mongo in favor of a new mongosh shell: https://github.com/mongodb-js/mongosh with much improved usability. Please consider giving it a try and let us know of any issues through the MONGOSH Jira project.

Comment by Kevin Pulo [ 20/Dec/18 ]

Note that SERVER-21493 means that using a shellHelper to solve this will fail (in the sense that the shell helper won't be run, and the user will again get a confusing error message) if the user enters a command which contains double quotes, which is not uncommon for these kinds of mongo/mongodump/mongoimport/etc commands.

Also, defining a "mongo" shellHelper will unfortunately subtly break interactive commands such as mongo = db.getMongo(). Whereas m = db.getMongo() — which ought to be equivalent — will (confusingly) succeed.

Comment by Shannon Bradshaw (Inactive) [ 19/Dec/18 ]

acm how do we know only a tiny handful have seen this problem? We see it frequently in the courses. 

Comment by Nathan Leniz [ 05/Dec/18 ]

In particular this one name seems to cause a significant amount of confusion for brand new users with no shell experience.

I wholly agree that we'd get a lot more mileage out of making error messages more helpful in general. The stars would be a "did you mean" type approach like git, kicking in if whatever the user typed resulted in an error.

Comment by Andrew Morrow (Inactive) [ 05/Dec/18 ]

Wouldn't we get a lot more mileage out of making those error messages more generally helpful, rather than overriding this one name?

Comment by Nathan Leniz [ 30/Nov/18 ]

Proposed PR: https://github.com/mongodb/mongo/pull/1279

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