Inconsistent BSON path traversal logic

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Execution
    • ALL
    • QE 2025-09-01, QE 2025-09-15, QE 2025-09-29
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      There are more than one implementation of extracting an element through a dotted path and they don't give the same results.

      Example test:

      TEST_F(ShardKeyPatternTest, RenDotted) {
          auto shardKeyBSON = BSON("a.b.c" << 1);
          ShardKeyPattern shardKeyPattern(shardKeyBSON);
          auto doc = BSON("a" << BSON("b.c" << 1 << "b" << BSON("c" << 2)));
      
          auto resultUsingInner = BSON("a.b.c" << 2);
          // This one is based on getFieldDottedOrArray in path_internal.cpp
          ASSERT_BSONOBJ_EQ(resultUsingInner, shardKeyPattern.extractShardKeyFromDoc(doc));
          // This one is used by getDocumentKey in op_observer_util.cpp, and this will fail the assertion
          ASSERT_BSONOBJ_EQ(resultUsingInner, bson::extractElementsBasedOnTemplate(doc, shardKeyBSON));
      }
      

            Assignee:
            Alberto Massari
            Reporter:
            Randolph Tan
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated: