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

ParsedAggregationProjection should prohibit mixing computed fields and exclusions

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.3.10
    • Affects Version/s: 3.3.9
    • Component/s: Aggregation Framework
    • None
    • Fully Compatible
    • ALL
    • Hide

      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
      
      Show
      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
    • Query 17 (07/15/16)
    • 0

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

            Assignee:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Reporter:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: