[SERVER-77590] Consolidate the validation paths for _id fields between inserts and updates Created: 30/May/23  Updated: 08/Jun/23

Status: Backlog
Project: Core Server
Component/s: Write Ops
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Chi-I Huang Assignee: Backlog - Query Optimization
Resolution: Unresolved Votes: 0
Labels: tech-debt
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-75517 illegal format of `_id` possible via ... Closed
is related to SERVER-75880 Upsert permits _id values containing ... Closed
Assigned Teams:
Query Optimization
Participants:

 Description   

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.


Generated at Thu Feb 08 06:36:01 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.