[SERVER-43840] Exclusion projection parser invariant trips on attempt to exclude reserved $-prefixed reserved field name Created: 04/Oct/19  Updated: 29/Oct/23  Resolved: 23/Oct/19

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: 4.3.1

Type: Bug Priority: Major - P3
Reporter: David Storch Assignee: Ian Boros
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

Any attempt to exclude one of the allowed $-prefixed path components will trigger this invariant:

> db.c.aggregate([{$unset: "$db"}])
> db.c.aggregate([{$project: {$ref: 0}}])
> db.c.aggregate([{$project: {"$textScore": 0}}])

Sprint: Query 2019-11-04
Participants:
Linked BF Score: 7

 Description   

In previous versions of the server, all $-prefixed path components were disallowed in the aggregation framework and, in particular, were disallowed in exclusion projections. As part of SERVER-42421, however, we introduced several reserved $-prefixed key names which are legal. These include "$ref", "$db", and "$id", which constitute DBRefs, as well as names used by the system internally to store metadata such as "$recordId", "$sortKey", and so on.

There is a lingering invariant in the exclusion projection parser which expects that the caller has rejected all $-prefixed field names. This invariant is no longer correct, since we permit certain reserved $-prefixed names as described above. We should remove or relax this incorrect invariant.



 Comments   
Comment by Githook User [ 23/Oct/19 ]

Author:

{'name': 'Ian Boros', 'username': 'puppyofkosh', 'email': 'ian.boros@mongodb.com'}

Message: SERVER-43840 fix invariant failure in exclusion projection parser
Branch: master
https://github.com/mongodb/mongo/commit/35fbf9bc919f0645b1269cd9916ce2509617e072

Comment by David Storch [ 04/Oct/19 ]

This was introduced in 4.3 development and therefore does not affect any stable branches, including 4.2.

Generated at Thu Feb 08 05:04:15 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.