Skip to content

pymongo errors aren't propagated properly  #20

Description

@odedfos

Errors originating from the pymongo driver aren't properly propagated to the application.

For instance, when performing a geospatial query when there is no 2dsphere index on the collection, I get the following error:

File "/project/env/local/lib/python2.7/site-packages/pymongo/cursor.py", line 977, in next
      if len(self.__data) or self._refresh():
File "/project/env/local/lib/python2.7/site-packages/pymongo/cursor.py", line 902, in _refresh
      self.__read_preference))
File "/project/env/local/lib/python2.7/site-packages/pymongo/cursor.py", line 839, in __send_message
      codec_options=self.__codec_options)
File "/project/env/local/lib/python2.7/site-packages/pymongo/helpers.py", line 112, in _unpack_response
      error_object = bson.BSON(response[20:]).decode()
AttributeError: 'module' object has no attribute 'BSON'

When I disable cbson with:
os.environ['MONGOKAT_DISABLE_CBSON'] = "1"

I get the proper error:

  File "/project/env/local/lib/python2.7/site-packages/pymongo/cursor.py", line 977, in next
    if len(self.__data) or self._refresh():
  File "/project/env/local/lib/python2.7/site-packages/pymongo/cursor.py", line 902, in _refresh
    self.__read_preference))
  File "/project/env/local/lib/python2.7/site-packages/pymongo/cursor.py", line 839, in __send_message
    codec_options=self.__codec_options)
  File "/project/env/local/lib/python2.7/site-packages/pymongo/helpers.py", line 122, in _unpack_response
    error_object)
OperationFailure: database error: error processing query: ns=test_test.pl_venue ntoreturn=100
Tree: GEONEAR  field=geolocation maxdist=100 isNearSphere=0
Sort: {}
Proj: {}
 planner returned error: unable to find index for $geoNear query

requirements:
pymongo==3.0.3
mongokat==0.1.4

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions