Description
Issue Description
On parse-server > 3.0.0, when querying a Class with a Geopoint filtered with $nearSphere and a count operator, mongodb returns an errors which is returned as an internal server error
by parse-server.
Queries
Queries does not return the same message depending on the parse-server version
-
parse-server >= 3.3.0 with
count=1&where={...$nearSphere...
error isMongoError: radius must be a non-negative number
(example query) -
parse-server >= 3.3.0 with
count=1&where={...$nearSphere...
error iserror: Uncaught internal server error.can't parse extra field: $maxDistance: 0.002525890376357666
(example query) -
parse-server > 3.0.0 & < 3.3.0 With count=1&where={...$nearSphere... error is
$nearSphere is not allowed inside of a $match aggregation expression
(example query) -
Works with 3.0.0
Steps to reproduce
Note: This (example query) with a count=1
in front of the where=...
curl -X GET \
-H "X-Parse-Application-Id: ${APPLICATION_ID}" \
-H "X-Parse-REST-API-Key: ${REST_API_KEY}" \
-G \
--data-urlencode 'count=1&where={
"location": {
"$nearSphere": {
"__type": "GeoPoint",
"latitude": 30.0,
"longitude": -20.0
},
"$maxDistanceInMiles": 10.0
}
}' \
https://YOUR.PARSE-SERVER.HERE/parse/classes/PlaceObject
Expected Results
What's in the doc: https://docs.parseplatform.org/rest/guide/#counting-objects
{
"results": [],
"count": 1337
}
Actual Outcome
Environment Setup
-
Server
- parse-server version 3.7.2 (KO with any version > 3.0.0)
- Operating System: Debian9
- Hardware: bare-metal
- Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): local
-
Database
- MongoDB version: Percona Server for MongoDB shell version v3.4.18-2.16
- Storage engine: engine: rocksdb
- Hardware: bare-metal
- Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): local
Logs/Trace
0|parse-se | 2019-08-23 12:18 +02:00: verbose: REQUEST for [GET] /v1/classes/Place?count=1&where={%20%20%20%20%20%20%20%20%22location%22:%20{%20%20%20%20%20%20%20%20%20%20%22$nearSphere%22:%20{%20%20%20%20%20%20%20%20%20%20%20%20%22__type%22:%20%22GeoPoint%22,%20%20%20%20%20%20%20%20%20%20%20%20%22latitude%22:%2030.0,%20%20%20%20%20%20%20%20%20%20%20%20%22longitude%22:%2020.0%20%20%20%20%20%20%20%20%20%20}%20%20%20%20%20%20%20%20}%20%20%20%20%20%20}: {} {"method":"GET","url":"/v1/classes/Place?count=1&where={ \"location\": { \"$nearSphere\": { \"__type\": \"GeoPoint\", \"latitude\": 30.0, \"longitude\": 20.0 } } }","headers":{"x-real-ip":"10.67.3.84","x-forwarded-for":"10.67.3.84","x-nginx-proxy":"true","host":"cobox-dev","connection":"close","sec-fetch-mode":"cors","x-parse-master-key":"REDACTED","x-parse-application-id":"OCPCoBox","user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36","accept":"*/*","sec-fetch-site":"same-origin","referer":"https://cobox-dev/board/apps/OCPCoBox/api_console","accept-encoding":"gzip, deflate, br","accept-language":"en-US,en;q=0.9,fr-FR;q=0.8,fr;q=0.7","cookie":"session=eyJjc3JmU2VjcmV0IjoiTWg4MTRVNHpFZTRudGpOendmOU9YemhCIiwiZmxhc2giOnt9LCJwYXNzcG9ydCI6eyJ1c2VyIjoib2NwZGV2In19; session.sig=msvh6QgaSsSwAsLMt622KFguiKc"},"body":{}}
0|parse-se | 2019-08-23 12:18 +02:00: error: Uncaught internal server error.radius must be a non-negative number {"ok":0,"errmsg":"radius must be a non-negative number","code":2,"codeName":"BadValue","name":"MongoError","stack":"MongoError: radius must be a non-negative number\n at Connection.<anonymous> (/opt/ocp/cube-parse-server/node_modules/mongodb-core/lib/connection/pool.js:443:61)\n at Connection.emit (events.js:180:13)\n at Connection.emit (domain.js:422:20)\n at processMessage (/opt/ocp/cube-parse-server/node_modules/mongodb-core/lib/connection/connection.js:364:10)\n at TLSSocket.<anonymous> (/opt/ocp/cube-parse-server/node_modules/mongodb-core/lib/connection/connection.js:533:15)\n at TLSSocket.emit (events.js:180:13)\n at TLSSocket.emit (domain.js:422:20)\n at addChunk (_stream_readable.js:274:12)\n at readableAddChunk (_stream_readable.js:261:11)\n at TLSSocket.Readable.push (_stream_readable.js:218:10)\n at TLSWrap.onread (net.js:581:20)"}
0|parse-se | 2019-08-23 12:18 +02:00: MongoError: radius must be a non-negative number
0|parse-se | at Connection.<anonymous> (/opt/ocp/cube-parse-server/node_modules/mongodb-core/lib/connection/pool.js:443:61)
0|parse-se | at Connection.emit (events.js:180:13)
0|parse-se | at Connection.emit (domain.js:422:20)
0|parse-se | at processMessage (/opt/ocp/cube-parse-server/node_modules/mongodb-core/lib/connection/connection.js:364:10)
0|parse-se | at TLSSocket.<anonymous> (/opt/ocp/cube-parse-server/node_modules/mongodb-core/lib/connection/connection.js:533:15)
0|parse-se | at TLSSocket.emit (events.js:180:13)
0|parse-se | at TLSSocket.emit (domain.js:422:20)
0|parse-se | at addChunk (_stream_readable.js:274:12)
0|parse-se | at readableAddChunk (_stream_readable.js:261:11)
0|parse-se | at TLSSocket.Readable.push (_stream_readable.js:218:10)
0|parse-se | at TLSWrap.onread (net.js:581:20)
Additonal notes:
Related to #5285?