[SERVER-24882] ParsedAggregationProjection should prohibit mixing computed fields and exclusions Created: 01/Jul/16  Updated: 19/Jul/16  Resolved: 01/Jul/16

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: 3.3.9
Fix Version/s: 3.3.10

Type: Bug Priority: Major - P3
Reporter: Max Hirschhorn Assignee: Max Hirschhorn
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

Simple steps to reproduce from kamran.khan and the fuzzer.

var coll = db.agg_project;
coll.insert({a: 1});
coll.aggregate([{$project: {a: {$literal: 1}, b: 0}}]).toArray();

Note that if the exclusion is specified first, then an error is correctly returned.

> coll.aggregate([{$project: {b: 0, a: {$literal: 1}}}]).toArray();
2016-07-01T15:45:14.290-0400 E QUERY    [thread1] Error: command failed: {
  "ok" : 0,
  "errmsg" : "Bad projection specification, cannot include fields or add computed fields during an exclusion projection: { b: 0.0, a: { $literal: 1.0 } }",
  "code" : 40182
} : aggregate failed :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
doassert@src/mongo/shell/assert.js:13:14
assert.commandWorked@src/mongo/shell/assert.js:264:5
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1299:5
@(shell):1:1

Sprint: Query 17 (07/15/16)
Participants:
Linked BF Score: 0

 Description   

This is currently caught as an invariant failure in ParsedExclusionProjection, but should result in a failed operation.



 Comments   
Comment by Githook User [ 01/Jul/16 ]

Author:

{u'username': u'visemet', u'name': u'Max Hirschhorn', u'email': u'max.hirschhorn@mongodb.com'}

Message: SERVER-24882 Reject expressions in aggregation's exclusion projection.
Branch: master
https://github.com/mongodb/mongo/commit/8757e22c07dcd098058f12be37c8495f31c84281

Generated at Thu Feb 08 04:07:40 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.