Currently there is no error code that signifies an invalid geojson.
If the creation 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.
Objectdb.geojson_test.createIndex({"geometry": "2dsphere"}){
"geometry": {"foo":"bar"}
}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.
A helpful error message, like the one returned by Mongo:
MongoError: Can't extract geo keys: ... unknown GeoJSON type: { foo: "bar" }
Server
4.5.0Ubuntu 18.04localDatabase
MongoDBv4.4.4localClient
anyFILL_THIS_OUTSee above
Thanks for reporting!
I agree that the server should not crash but provide a proper error message. The steps would be:
This issue has been classified as bug with severity S4 (small/trivial):
I have created a PR for the new error code
parse-community/Parse-SDK-JS#1342
The error code PR has been merged.
The error code won't be available until a new Parse JS SDK will be released and the dependency in Parse Server is updated. But you can already expect the Parse Error and write tests for it, they will just fail for now.
Most helpful comment
Thanks for reporting!
I agree that the server should not crash but provide a proper error message. The steps would be: