[SERVER-84598] $geoNear allows missing or invalid GeoJSON "type" field Created: 05/Jan/24  Updated: 06/Feb/24  Resolved: 06/Feb/24

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.3.0-rc0

Type: Bug Priority: Major - P3
Reporter: Will Buerger Assignee: Ted Tuckman
Resolution: Fixed Votes: 0
Labels: neweng, qi-geo
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Documented
is documented by DOCS-16634 [SERVER] Investigate changes in SERVE... Backlog
Gantt Dependency
has to be done before SERVER-86141 Audit calls to the geoParser and asse... Needs Scheduling
Related
related to SERVER-84630 $geoNear fails to re-parse when provi... Closed
Assigned Teams:
Query Integration
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

Run any $near or $geoNear match expressions, or $geoNear aggregation stage, with the near value as {$geometry: {type: <insert any gibberish here>, coordinates: [0,0]}} will be accepted, as long as there are 2 coordinates wrapped in an array for the coordinates field.

Participants:

 Description   

Most geo queries that are built on top of geometry_container do not allow an unknown or missing "type" field. However, $geoNear (match expression and agg stage) rely instead on `GeoNearExpression`, which skips the geometry_container layer, so it accepts a missing or invalid GeoJSON "type" field, and will treat it as type "Point". In fact, it would even accept the type field as any GeoJSON type, since it doesn't check the "type" field. This is misleading, and inconsistent with the other geo operators.

As part of this ticket, we should consider incorporating geometry_container as part of GeoNearExpression to match behavior parity across geo expressions.



 Comments   
Comment by Githook User [ 06/Feb/24 ]

Author:

{'name': 'Ted Tuckman', 'email': 'ted.tuckman@mongodb.com', 'username': 'TedTuckman'}

Message: SERVER-84598 Verify 'type' field is a valid string in geo queries

GitOrigin-RevId: a12bc613e2d94c85bb2c386538ecf25c8315d05d
Branch: master
https://github.com/mongodb/mongo/commit/ad2d6e80d60ce2198a7711828f7e619a0baf3c2f

Generated at Thu Feb 08 06:55:28 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.