parse-community / parse-community/parse-server
Error Code for Invalid Geojson
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 21.4k
- Forks
- 4.8k
- Avg merge
- 7h 45m
- Merged PRs (30d)
- 11
Description
New Issue Checklist
- [ x] I am not disclosing a vulnerability.
- [ x] I am not just asking a question.
- [ x] I have searched through existing issues.
- [ x] I can reproduce the issue with the latest version of Parse Server.
Issue Description
Currently there is no error code that signifies an invalid geojson.
If the creation or the update of an object fails due to a column with a geospatial index (such as 2dsphere) containing invalid data, Parse throws a generic INTERNAL_SERVER_ERROR with no information as to exactly what went wrong.
Note that this corresponds to the Mongo error code 16755.
Steps to reproduce
- Create a new class, geojson_test
- Create a new column, called geometry, of type
Object
You can use the dashboard for both of these steps - Create a geospatial index using the mongo shell:
db.geojson_test.createIndex({"geometry": "2dsphere"}) - Attempt to create this object, using any sdk (JS, rest, ...):
{ "geometry": {"foo":"bar"} }
One can also create an object with an empty geometry field and later attempt to update it to { "geometry": {"foo":"bar"}} and get the same behaviour.
Actual Outcome
Parse throws a generic INTERNAL_SERVER_ERROR with no information as to exactly what went wrong:
{
"code": 1,
"message": "Internal server error."
}
This makes it difficult to handle invalid geojsons programmatically.
Note that the original Mongo exception gets logged by Parse, but is programmatically inaccessible.
Expected Outcome
A helpful error message, like the one returned by Mongo:
MongoError: Can't extract geo keys: ... unknown GeoJSON type: { foo: "bar" }
Failing Test Case / Pull Request
- 🤩 I submitted a PR with a fix and a test case.
- 🧐 I submitted a PR with a failing test case.
Environment
Server
- Parse Server version:
4.5.0 - Operating system:
Ubuntu 18.04 - Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc):
local
Database
- System (MongoDB or Postgres):
MongoDB - Database version:
v4.4.4 - Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc):
local
Client
- SDK (iOS, Android, JavaScript, PHP, Unity, etc):
any - SDK version:
n/a
Logs
See above
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with a MongoDB 2dsphere index and the invalid geometry shown in the issue, then trace how the Mongo exception becomes Parse's INTERNAL_SERVER_ERROR. Done means invalid GeoJSON produces a helpful, programmatically accessible error and the behavior is covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, mongodb, node.js
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100