[SERVER-12546] Misleading error message "Invalid modifier specified: $set" Created: 30/Jan/14  Updated: 30/Jan/14  Resolved: 30/Jan/14

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

Type: Improvement Priority: Minor - P4
Reporter: Dan Dascalescu Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

The error message Invalid modifier specified: $set, at a first glance, suggests that '$set' itself is an invalid modifier. I'm not the only one to read it that way; see also this StackOverflow comment.

This happens when (accidentally) running an update() with {$set: null}.

The message would be less misleading and more useful if it output the precise value of the modifier (not just $set). For example:

Invalid modifier specified for $set: null



 Comments   
Comment by Scott Hernandez (Inactive) [ 30/Jan/14 ]

In the current code this is no longer the message. Instead you get this;

> db.coll.update({}, {$set:null})
2014-01-30T10:33:42.792-0500 trying reconnect to 127.0.0.1:27017 (127.0.0.1) failed
2014-01-30T10:33:42.793-0500 reconnect 127.0.0.1:27017 (127.0.0.1) ok
...                        "errmsg" : "Modifiers operate on fields but we found a NULL instead. For example: {$mod: {<field>: ...}} not {$set: null}",

This will be avaiable with the 2.5.3+ dev releases and in the 2.6 stable production release when it comes out. If you think this message is not what you want, please make a comment and we can re-open this.

Generated at Thu Feb 08 03:28:50 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.