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

XMLWordPrintableJSON

    • Query Execution
    • Minor Change
    • QE 2024-03-04, QE 2024-03-18, QE 2024-04-01, QE 2024-04-15, QE 2024-04-29, QE 2024-05-13, QE 2024-05-27, QE 2024-06-10, QE 2024-06-24, QE 2024-07-08, QE 2024-07-22, QE 2024-08-05, QE 2024-08-19, QE 2024-09-02, QE 2024-09-16, QE 2024-09-30, QE 2024-10-14, QE 2024-10-28, QE 2026-01-19
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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:
            Lyublena Antova
            Reporter:
            Jérôme Tamarelle
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: