Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-25604

Improve readability/usefulness of $replaceRoot error messages

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.4.0-rc4
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • None
    • Fully Compatible
    • Query 2016-11-21

      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.

            Assignee:
            david.storch@mongodb.com David Storch
            Reporter:
            charlie.swanson@mongodb.com Charlie Swanson
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: