$geoNear: Misleading error message when coordinates array is invalid #15188
Labels
has repro script
There is a repro script, the Mongoose devs need to confirm that it reproduces the issue
Milestone
Mongoose version
^8.0.0
Description
The
$geoNear
aggregation stage produces a misleading error message when performing GeoJSON point queries with invalid coordinates. When the coordinates array in the near parameter isundefined
or invalid (e.g.[]
), instead of indicating the coordinate validation issue, it incorrectly suggests there's a problem with having multiple arguments:This error message is confusing because:
maxDistance
parameter is valid and supported by$geoNear
Steps to Reproduce
Copy and paste the code into any project with Typescript and mongoose 8.x,
npm i
and then run the script with Node.Note: The provided snippet uses an in-memory instance for ease of reproduction, but the behaviour is identical with a proper connection.
Expected Behaviour
The error message should clearly indicate that the coordinates array is invalid instead of suggesting the removal of a valid parameter (
maxDistance
).The text was updated successfully, but these errors were encountered: