[SERVER-13815] Add field path to the "Cannot apply {x} modifier to non-array" error message Created: 02/May/14  Updated: 02/May/14  Resolved: 02/May/14

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

Type: New Feature Priority: Trivial - P5
Reporter: Jonathan H. Wage Assignee: Unassigned
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

Having a field path in that error message would be helpful for tracking down where the bad data is located in order to clean it up.



 Comments   
Comment by Jonathan H. Wage [ 02/May/14 ]

Thanks Jeremy, I think you can close this then.

Comment by Jeremy Mikola [ 02/May/14 ]

jwage: On 2.6.0, the error messages are a bit more verbose:

$ mongo
MongoDB shell version: 2.6.0
connecting to: test
> db.foo.drop()
true
> db.foo.insert({x:5})
WriteResult({ "nInserted" : 1 })
> db.foo.update({x:5},{$push:{'x': 'a'}})
WriteResult({
	"nMatched" : 0,
	"nUpserted" : 0,
	"nModified" : 0,
	"writeError" : {
		"code" : 16837,
		"errmsg" : "The field 'x' must be an array but is of type NumberDouble in document {_id: ObjectId('5363b8b3d52e93ecd4cfc43c')}"
	}
})

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