[SERVER-53344] Validator expression with $geoWithin reports incorrect error message Created: 14/Dec/20  Updated: 29/Oct/23  Resolved: 08/Jan/21

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

Type: Bug Priority: Major - P3
Reporter: Mihai Andrei Assignee: Mihai Andrei
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Query 2021-01-11
Participants:

 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.



 Comments   
Comment by Ian Whalen (Inactive) [ 09/Jan/21 ]

Author:

{'username': u'evrg-bot-webhook', 'name': u'Mihai Andrei', 'email': u'mihai.andrei@10gen.com'}

Message:SERVER-53344 Validator expression with $geoWithin reports incorrect error message
Branch:master
https://github.com/mongodb/mongo/commit/408b7f62561e50c312dff4dc0327923359d83248

Generated at Thu Feb 08 05:30:38 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.