Uploaded image for project: 'MongoDB Shell'
  1. MongoDB Shell
  2. MONGOSH-1397

Mongo shell throws Uncaught SyntaxError on Collection Name

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Minor - P4 Minor - P4
    • No version
    • Affects Version/s: 1.7.1
    • Component/s: Shell API
    • Labels:
      None
    • Environment:
    • Not Needed

      Problem Statement/Rationale

      mongosh does not verify the collection name upon creation, and it will throw an Uncaught:
      SyntaxError: Identifier directly after number. (1:4).

      Please be sure to attach relevant logs with any sensitive data redacted.

      Steps to Reproduce

      How could an engineer replicate the issue you're reporting?

       

      // code placeholder
      test> db.createCollection("0x123")
      { ok: 1 }
      
       test> db.0x123.distinct()
      Uncaught:
      SyntaxError: Identifier directly after number. (1:4)> 1 | db.0x123.distinct()
          |     ^
        2 |test> 

       

      Expected Results

      What do you expect to happen?

      When creating a collection, it should verify that the collection name matches the naming constraints.

      Actual Results

      What do you observe is happening?

      An uncaught SyntaxError: Identifier directly after number.

      Additional Notes

      Any additional information that may be useful to include.

            Assignee:
            Unassigned Unassigned
            Reporter:
            jncuisiwei@gmail.com Siwei Cui
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: