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

Validator expression with $geoWithin reports incorrect error message

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • 4.9.0
    • None
    • None
    • None
    • Fully Compatible
    • ALL
    • Query 2021-01-11

    Description

      Consider the following validator expression:

      { coordinates: {$geoWithin: { $centerSphere: [ [ -79.9081268, 9.3547792 ], 0.02523 ] } } }
      

      Inserting the document

      {coordinates: [ -72.5419922, 18.2312794 ]}
      

      produces the following error.

      WriteResult({
        "nInserted": 0,
        "writeError": {
          "code": 121,
          "errmsg": "Document failed validation",
          "errInfo": {
            "failingDocumentId": ObjectId("5fd6918a42c10f01eeca6658"),
            "details": {
              "operatorName": "$geoWithin",
              "specifiedAs": {
                "coordinates": {
                  "$geoWithin": {
                    "$centerSphere": [
                      [
                        -79.9081268,
                        9.3547792
                      ],
                      0.002523
                    ]
                  }
                }
              },
              "reason": "type did not match",
              "consideredType": "double",
              "expectedTypes": [
                "array",
                "object"
              ],
              "consideredValues": [
                -72.5419922,
                18.2312794
              ]
            }
          }
        }
      

      The detailed error incorrectly reports a type mismatch error, when instead it should report the following error string.

      This bug reflects an issue with type checking when generating document validator errors.

      Attachments

        Activity

          People

            mihai.andrei@mongodb.com Mihai Andrei
            mihai.andrei@mongodb.com Mihai Andrei
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: