Nested $elemMatch query can uassert when multiple predicates are present

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 8.3.0-rc0
    • Affects Version/s: 8.0.13, 8.3.0-rc0, 7.0.25-alpha0
    • Component/s: None
    • Query Optimization
    • Fully Compatible
    • ALL
    • v8.2, v8.0, v7.0
    • Hide
      const coll = db.coll;
      assert(coll.drop());
      assert.commandWorked(coll.insert([{}]));
      
      const q = [
          {
              "$addFields": {
                  "a": 0,
              },
          },
          {
              "$match": {
                  "a": {
                      "$elemMatch": {
                          "$elemMatch": {
                              "$eq": 0,
                          },
                          "$in": [0],
                      },
                  },
              }
          },
          {
              "$project": {
                  "_id": 0,
                  "a": 1,
              },
          },
      ];
      
      coll.aggregate(q).toArray();
      // uassert: FieldPath cannot be constructed with empty string
      
      Show
      const coll = db.coll; assert (coll.drop()); assert .commandWorked(coll.insert([{}])); const q = [ { "$addFields" : { "a" : 0, }, }, { "$match" : { "a" : { "$elemMatch" : { "$elemMatch" : { "$eq" : 0, }, "$in" : [0], }, }, } }, { "$project" : { "_id" : 0, "a" : 1, }, }, ]; coll.aggregate(q).toArray(); // uassert: FieldPath cannot be constructed with empty string
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Repro shows a valid query with nested $elemMatch hitting a uassert. It looks very similar to SERVER-101795, but at the time of filing that the issue was only reproducible on a time-series collection. This bug occurs on a regular collection.

      The uassert is hit during "createCanonicalQuery", so assigning it to Query Optimization for now.

            Assignee:
            Alya Berciu
            Reporter:
            Matt Boros
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved: