Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throwing exception when polygon is not closed. #1430

Open
yuregir opened this issue Dec 22, 2020 · 1 comment
Open

Throwing exception when polygon is not closed. #1430

yuregir opened this issue Dec 22, 2020 · 1 comment
Labels

Comments

@yuregir
Copy link

yuregir commented Dec 22, 2020


Expected Behavior

When I want to POST the Polygon object, if loop is not closed (when first coordinate and last coordinate is not same). It should display proper Http error code and schema error message.

in settings.py location field defined as:

'location': {'type': 'polygon'},

Example payload

{
    "name": "Dev6",
    "location": {
        "type": "Polygon",
        "coordinates": [[
      [-101.0, -10.0], [10.0, -10.0], [10.0, 10.0], [-10.0, -10.0]
    ]]
    }
}

Actual Behavior

PyMongo driver throwing exception, not handled properly.

12/22/2020 10:41:17 PM ERROR in mongo: batch op errors occurred, full error: {'writeErrors': [{'index': 0, 'code': 16755, 'errmsg': 'Can\'t extract geo keys: { _id: ObjectId(\'5fe24bdd0092f37e63de0697\'), name: "Dev6", description: "Test", organizationId: ObjectId(\'5a7f11dde2cd7a15e0a5a0f3\'), location: { type: "Polygon", coordinates: [ [ [ -101.0, -10.0 ], [ 10.0, -10.0 ], [ 10.0, 10.0 ], [ -10.0, -10.0 ] ] ] }, _updated: new Date(1608666077000), _created: new Date(1608666077000), _etag: "3662d68520f26936de021c1e1a9c6875b345647b" } Loop is not closed: [ [ -101.0, -10.0 ], [ 10.0, -10.0 ], [ 10.0, 10.0 ], [ -10.0, -10.0 ] ]', 'op': {'name': 'Dev6', 'description': 'Test', 'organizationId': ObjectId('5a7f11dde2cd7a15e0a5a0f3'), 'location': {'type': 'Polygon', 'coordinates': [[[-101.0, -10.0], [10.0, -10.0], [10.0, 10.0], [-10.0, -10.0]]]}, '_updated': datetime.datetime(2020, 12, 22, 19, 41, 17), '_created': datetime.datetime(2020, 12, 22, 19, 41, 17), '_etag': '3662d68520f26936de021c1e1a9c6875b345647b', '_id': ObjectId('5fe24bdd0092f37e63de0697')}}], 'writeConcernErrors': [], 'nInserted': 0, 'nUpserted': 0, 'nMatched': 0, 'nModified': 0, 'nRemoved': 0, 'upserted': []}
12/22/2020 10:41:17 PM Traceback (most recent call last):
12/22/2020 10:41:17 PM File "/usr/local/lib/python3.6/site-packages/eve/io/mongo/mongo.py", line 468, in insert
12/22/2020 10:41:17 PM return coll.insert_many(doc_or_docs, ordered=True).inserted_ids
12/22/2020 10:41:17 PM File "/usr/local/lib/python3.6/site-packages/pymongo/collection.py", line 761, in insert_many
12/22/2020 10:41:17 PM blk.execute(write_concern, session=session)
12/22/2020 10:41:17 PM File "/usr/local/lib/python3.6/site-packages/pymongo/bulk.py", line 528, in execute
12/22/2020 10:41:17 PM return self.execute_command(generator, write_concern, session)
12/22/2020 10:41:17 PM File "/usr/local/lib/python3.6/site-packages/pymongo/bulk.py", line 363, in execute_command
12/22/2020 10:41:17 PM _raise_bulk_write_error(full_result)
12/22/2020 10:41:17 PM File "/usr/local/lib/python3.6/site-packages/pymongo/bulk.py", line 140, in _raise_bulk_write_error
12/22/2020 10:41:17 PM raise BulkWriteError(full_result)
12/22/2020 10:41:17 PM pymongo.errors.BulkWriteError: batch op errors occurred, full error: {'writeErrors': [{'index': 0, 'code': 16755, 'errmsg': 'Can\'t extract geo keys: { _id: ObjectId(\'5fe24bdd0092f37e63de0697\'), name: "Dev6", location: { type: "Polygon", coordinates: [ [ [ -101.0, -10.0 ], [ 10.0, -10.0 ], [ 10.0, 10.0 ], [ -10.0, -10.0 ] ] ] }, _updated: new Date(1608666077000), _created: new Date(1608666077000), _etag: "3662d68520f26936de021c1e1a9c6875b345647b" } Loop is not closed: [ [ -101.0, -10.0 ], [ 10.0, -10.0 ], [ 10.0, 10.0 ], [ -10.0, -10.0 ] ]', 'op': {'name': 'Dev6', 'location': {'type': 'Polygon', 'coordinates': [[[-101.0, -10.0], [10.0, -10.0], [10.0, 10.0], [-10.0, -10.0]]]}, '_updated': datetime.datetime(2020, 12, 22, 19, 41, 17), '_created': datetime.datetime(2020, 12, 22, 19, 41, 17), '_etag': '3662d68520f26936de021c1e1a9c6875b345647b', '_id': ObjectId('5fe24bdd0092f37e63de0697')}}], 'writeConcernErrors': [], 'nInserted': 0, 'nUpserted': 0, 'nMatched': 0, 'nModified': 0, 'nRemoved': 0, 'upserted': []}

Environment

  • Python version: 3.6
  • Eve version: 1.1.4

Other Packages

  • Package Version

bjoern 3.1.0
blinker 1.4
Cerberus 1.3.2
certifi 2020.12.5
chardet 3.0.4
click 7.1.2
elasticsearch 7.10.1
Eve 1.1.4
Eve-Swagger 0.1.3
Events 0.3
Flask 1.1.2
Flask-Cors 3.0.9
Flask-Mail 0.9.1
greenlet 0.4.17
gunicorn 20.0.4
idna 2.10
itsdangerous 1.1.0
Jinja2 2.11.2
MarkupSafe 1.1.1
meinheld 1.0.2
pip 19.1.1
pymongo 3.11.2
python-dateutil 2.8.1
requests 2.25.0
setuptools 41.0.1
simplejson 3.17.2
six 1.15.0
swagger-client 1.0.0
urllib3 1.26.2
Werkzeug 1.0.1
wheel 0.33.1

@stale
Copy link

stale bot commented Apr 16, 2022

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale label Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant