Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-85768

Improve error message when $documents stage is used on a collection aggregation

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 7.0.5
    • Component/s: None
    • Labels:
    • Query Execution
    • QE 2024-03-04, QE 2024-03-18, QE 2024-04-01, QE 2024-04-15, QE 2024-04-29, QE 2024-05-13

      Running the following command on mongo v7.0.5, the error message wasn't clear for me.

      Enterprise test> db.test.aggregate([ { $documents: [{ nb: [1, 2, 3] }] }, { $project: { total: { $sum: ["$nb"] } } }] )
      MongoServerError: '$documents' can only be run with {aggregate: 1}

      I didn't know {aggregate: 1} was the literal expression of a database or cluster-level aggregation.

      Could you change the error message to make it more explicit:

      MongoServerError: '$documents' can only be run with database or cluster-level aggregation {aggregate: 1}

            Assignee:
            kyle.suarez@mongodb.com Kyle Suarez
            Reporter:
            jerome.tamarelle@mongodb.com Jérôme Tamarelle
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: