findOneAndUpdate with upsert & setDefaultsOnInsert options returns MongoServerError on nested object properties update #12279
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Prerequisites
Mongoose version
6.5.2
Node.js version
14.20.0
MongoDB server version
4.4.15
Description
MongoServerError: Updating the path 'x.y' would create a conflict at 'x' received after an attempt to update nested object properties using findOneAndUpdate with upsert & setDefaultsOnInsert options.
Steps to Reproduce
Model and Query:
Result:
Expected Behavior
New document created, based on: FilterQuery, subscriptionsConfig options in $set and default in Schema.
The text was updated successfully, but these errors were encountered: