Operational Defect Database

BugZero found this defect 2377 days ago.

MongoDB | 420109

[SERVER-30822] Update does not give an error message when $setOnInsert fails on FCV 3.6

Last update date:


Affected products:

MongoDB Server

Affected releases:



Fixed releases:

No fixed releases provided.



After setting FCV to 3.6 on 3.5.12, the mongo shell session appears as from the repro. This is different from FCV 3.4, which would give the following response: WriteResult({ "nMatched" : 0, "nUpserted" : 0, "nModified" : 0, "writeError" : { "code" : 16837, "errmsg" : "cannot use the part (a of a.b) to traverse the element ({a: 1.0})" } }) In the example, field 'a' can actually be nearly any data type including a number, a string, an array, NaN, null, or undefined. This difference can also be observed regardless of whether multi or upsert is set to true / false. FCV 3.6 would return nMatched as the number of documents matching the <find> portion of the query. The WriteResult given in FCV 3.6 may not accurately reflect a reason (or reflect a reason at all) for why no documents were upserted / modified, especially when upsert is set to true.

Top User Comments

ian@10gen.com commented on Tue, 5 Sep 2017 14:51:43 +0000: Per Tess' comment above this was a bug in 3.4 which was fixed in 3.6 and we are not backporting the fix to 3.4. tess.avitabile commented on Fri, 25 Aug 2017 15:44:26 +0000: This is a bug on 3.4 and 3.6 featureCompatibilityVersion 3.4. We call prepare() on the ModifierInterface for $setOnInsert even in an update context, when we will not apply it. Then if there is a blocking element and the $setOnInsert cannot be applied, we return an error, even though we were not going to apply the $setOnInsert. On 3.4. On 3.6 featureCompatibilityVersion 3.4.

Additional Resources / Links


BugZero Risk Score

Coming soon



Have you been affected by this bug?


Do you know how much operational outages are costing you?

Understand the cost to your business and how BugZero can help you reduce those costs.


Login to read and write comments.

Have you ever...

had your data corrupted from a