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

Consolidate the validation paths for _id fields between inserts and updates

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Write Ops
    • Labels:
    • Query Optimization

      There is a divergence of the validation path for _id fields between inserts & updates. We should refactor these two paths (and any additional create/update validation paths, if they exist) to rely on the same validation logic for consistency and increased test coverage.

      The validation is defined:

      Background

      Originally, we were using storageValidEmbedded method in updates. The call stack was like:

      1. storage_validation::scanDocument
      2. → storage_validation::storageValidIdField
      3. → BSONObj::storageValidEmbedded.

      Later in SERVER-75517, we moved away from using the storageValidEmbedded method as it is not compatible for use with ConstElements, as described in the ticket. We have duplicate validation logic between storage and inserts.

      Due to this divergence, we had the issues SERVER-75879 and SERVER-75880 where we permitted upserting an invalid document which is not by an insert.

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            chii.huang@mongodb.com Chi-I Huang
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: