[SERVER-25604] Improve readability/usefulness of $replaceRoot error messages Created: 15/Aug/16  Updated: 19/Nov/16  Resolved: 09/Nov/16

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: 3.4.0-rc4

Type: Improvement Priority: Major - P3
Reporter: Charlie Swanson Assignee: David Storch
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-23313 Add a $replaceRoot stage which allows... Closed
Backwards Compatibility: Fully Compatible
Sprint: Query 2016-11-21
Participants:

 Description   

As Asya pointed out in a comment on SERVER-23313:

I don't think this error message is always correct/helpful:

"errmsg" : " 'newRoot' argument to $replaceRoot stage must evaluate to a valid Value, try ensuring that your field path(s) exist by prepending a $match: {<path>: $exists} aggregation stage.",

If the field (say "$a") is not an object we correctly say

try ensuring that it evaluates to an object by prepending a $match: {<path>: {$type: 'object'}}

Is there a reason not to always say that even if the field is missing? Also if path is missing or there but null they don't need to match, they might need to $ifNull inside newRoot, maybe to preserve document counts or fill in some default values.

Also they might correct such errors via checking $type of path (in addition or instead of $ifNull) to fill in default values...

We should take some time to ensure these error messages are clear and helpful, without proposing a solution that might not always be ideal.



 Comments   
Comment by Githook User [ 09/Nov/16 ]

Author:

{u'username': u'dstorch', u'name': u'David Storch', u'email': u'david.storch@10gen.com'}

Message: SERVER-25604 fix $replaceRoot error message
Branch: master
https://github.com/mongodb/mongo/commit/0a91c903c4dee2e6cd39f0b9d6dd2b639a137aab

Generated at Thu Feb 08 04:09:39 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.