Currently, if the client document for merge has the first field starting with '$', it may be treated as a modifier style update, even when the intention is always a replacement style update. This triggered the invariant in the linked BF.
However, even if we fix the invariant, supporting $merge with dollar fields across the board is harder than expected. For example, if the merge strategy results in a modifier style update, having a dollar field in the updated document will trigger validation assertion down the line. Even if it's a replacement style update, it still may trigger validation assertion after experiments.
To be relatively consistent instead of only supporting dollar fields in some combination of merge strategies, we can also consider rejecting the dollar fields except for the pipeline style update.
- related to
-
SERVER-76999 Generate consistent errors for updating $merge with dollar fields document
- Backlog