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

Mongosh cuts output after pipe

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.6.2
    • Affects Version/s: None
    • Component/s: CLI Module
    • Labels:
      None
    • Environment:
      Mongodb:5.0.10 - 6.0.2
      Docker container
    • 5
    • Not Needed
    • Iteration Porpoise

      Problem Statement/Rationale

      Mongosh command cuts off the output when it's really long.

      Steps to Reproduce

      Install mongodb:5.0.10 - 6.0.2 and try to use following command on big collection:

      mongosh --quiet -host <host> -port <port> -u <username> -p <password> <dbname> --eval EJSON.stringify(db.<collectionName>.find().toArray(),null,2) | more
      

       

      Expected Results

      Print entire collection represented as Array and pass it to the "more" command, which helps you go through

      Actual Results

      Command output gets cut off, which makes JSON unserializable and incompatibile with standard JSON output format.

      Additional Notes

      When I found this bug i used python3.8.10 with subprocess library.
      Command that I used: 

      result = subprocess.Popen(<full_command>, stdout=PIPE)

      NOTE: stdout=PIPE works the same way as | operator, but enables you to store output in "result" variable

            Assignee:
            anna.henningsen@mongodb.com Anna Henningsen
            Reporter:
            rainflywave@gmail.com Samson Kustra
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: