[SERVER-75880] Upsert permits _id values containing $-prefixed paths which cannot be inserted using insert command Created: 08/Apr/23  Updated: 29/Oct/23  Resolved: 30/May/23

Status: Closed
Project: Core Server
Component/s: Write Ops
Affects Version/s: 6.0.0, 5.0.16, 6.3.0-rc3
Fix Version/s: 7.1.0-rc0

Type: Bug Priority: Major - P3
Reporter: Max Hirschhorn Assignee: Chi-I Huang
Resolution: Fixed Votes: 0
Labels: query-director-triage
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Problem/Incident
Related
related to SERVER-77858 Collection validation and dbCheck sho... Open
related to SERVER-77590 Consolidate the validation paths for ... Backlog
is related to SERVER-75517 illegal format of `_id` possible via ... Closed
Assigned Teams:
Query Optimization
Backwards Compatibility: Minor Change
Operating System: ALL
Backport Requested:
v7.0, v6.3, v6.0, v5.0
Sprint: QO 2023-05-29, QO 2023-06-12
Participants:

 Description   

This is a continuation to SERVER-75517 where the changes from 819f9d1 made it so the server checks the top-level fields within an _id embedded object do not start with a '$' character. The non top-level fields in the _id embedded object won't be validated for '$' characters by an update using upsert=true. The upsert behavior diverges from the storage_validation::storageValidIdField() / BSONObj::storageValidEmbedded() behavior called by the insert command via fixDocumentForInsert() in which the latter recursive checks that fields in embedded objects and arrays at any level do not start with a '$' character.

This difference in behavior between [updates using upsert=true] and inserts would prevent tools like mongosync which perform a logical sync from successfully copying over the documents. Probably the documents should be prevented from being upserted to preserve the pre PM-1856 behavior for the _id field.



 Comments   
Comment by Githook User [ 29/May/23 ]

Author:

{'name': 'Chi-I Huang', 'email': 'chii.huang@mongodb.com', 'username': 'chiihuang'}

Message: SERVER-75880: Added isEmbeddedInIdField flag to disallow $-prefixed fields in _id field
Branch: master
https://github.com/mongodb/mongo/commit/139c0f6e6f7c7c20e08e1996d38fed3073e5bf94

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