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

_id validation for insert is missing from $set, $setOnInsert in updates

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 5.0.0-rc2, 5.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
    • Fully Compatible
    • ALL
    • v5.0
    • Hide

      db.coll.drop()

      db.coll.update({a: 1}, {$setOnInsert: { _id:

      { $first: 1}

      } }, {upsert: true})

      (Should fail, but doesn't)

      Show
      db.coll.drop() db.coll.update({a: 1}, {$setOnInsert: { _id: { $first: 1} } }, {upsert: true}) (Should fail, but doesn't)
    • Query Optimization 2021-06-14
    • 150

      The mitigate pain of dots and dollars project removed validation to allow documents with $-prefixed fields to be inserted. However, validation to prevent _id fields containing documents with $-prefixed fields was kept.

      This validation is not present on the update path when an upsert happens, because upserts relied on storage_validation.cpp for validation, whereas insert has separate validation logic to handle this case. This allows documents like {_id: {$foo: 1}} to be inserted via an update with upsert set to true, causing BF-21347

      We should ensure that the validation on _id fields which are objects which normally happens when a document is being inserted also happens when a document is being upserted.

       

            Assignee:
            alya.berciu@mongodb.com Alya Berciu
            Reporter:
            alya.berciu@mongodb.com Alya Berciu
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: