parse-community / parse-community/parse-server

Error Code for Invalid Geojson

Open
#7,331 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type:bug
Dominant language
JavaScript
Stars
21.4k
Forks
4.8k
Avg merge
7h 45m
Merged PRs (30d)
11

Description

New Issue Checklist
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
  1. Create a new class, geojson_test
  2. Create a new column, called geometry, of type Object
    You can use the dashboard for both of these steps
  3. Create a geospatial index using the mongo shell:
    db.geojson_test.createIndex({"geometry": "2dsphere"})
  4. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.