Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-3100

"Unexpected error. 'cursor'" on listCollections command

    • Type: Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 4.0.1, 3.12.3
    • Component/s: Command Ops
    • None

      Trace

      Trace was obtained on version 3.12.3:

      builtins.KeyError: 'cursor'
      Traceback (most recent call last):
      
      File "/opt/venv/lib/python3.7/site-packages/ddtrace/contrib/pymongo/patch.py", line 84, in traced_get_socket yield sock_info
      
      File "/opt/venv/lib/python3.7/site-packages/ddtrace/contrib/pymongo/client.py", line 156, in get_socket yield s
      
      File "/opt/venv/lib/python3.7/site-packages/pymongo/mongo_client.py", line 1321, in _get_socket yield sock_info
      
      File "/opt/venv/lib/python3.7/site-packages/pymongo/mongo_client.py", line 1374, in _secondaryok_for_server yield sock_info, secondary_ok
      
      File "/opt/venv/lib/python3.7/site-packages/pymongo/mongo_client.py", line 1525, in _retryable_read return func(session, server, sock_info, secondary_ok)
      
      File "/opt/venv/lib/python3.7/site-packages/pymongo/database.py", line 846, in _cmd **kwargs)
      
      File "/opt/venv/lib/python3.7/site-packages/pymongo/database.py", line 794, in _list_collections session=tmp_session)["cursor"]
      
      KeyError: 'cursor'
      

      Last line context:

      cmd = SON([("listCollections", 1), ("cursor", {})])
      cmd.update(kwargs)
      with self.__client._tmp_session(session, close=False) as tmp_session:
        cursor = self._command(
         sock_info, cmd, secondary_okay,
         read_preference=read_preference,
         session=tmp_session)["cursor"]
      

       

      The listCollections API doc (https://docs.mongodb.com/manual/reference/command/listCollections/) states that the listCollections command does not accept a "cursor" argument, and if I understood well, that's what cmd tries to do here. 

      Python Version: 3.7.8

      Pymongo Version: 3.12.3

      Operating System: Ubuntu 20.04

            Assignee:
            julius.park@mongodb.com Julius Park (Inactive)
            Reporter:
            marc.brun@cybelangel.com Marc Brun
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: