[SERVER-85768] Improve error message when $documents stage is used on a collection aggregation Created: 26/Jan/24  Updated: 02/Feb/24

Status: Needs Scheduling
Project: Core Server
Component/s: None
Affects Version/s: 7.0.5
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Jérôme Tamarelle Assignee: Backlog - Query Execution
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to DOCS-16604 $documents stage can't be used on a c... Backlog
Assigned Teams:
Query Execution
Participants:

 Description   

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}


Generated at Thu Feb 08 06:58:34 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.