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

Use error code to check for NamespaceNotFound errors

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 3.11
    • API
    • None

    Description

      In SERVER-37726 the server changed its NamespaceNotFound error message from "ns not found" to "ns not found <db.coll>". This breaks certain pymongo apis which (unfortunately) rely on error message checking:

       [2020/02/18 13:04:07.388] ======================================================================
       [2020/02/18 13:04:07.389] ERROR [0.010s]: test_create_index (test_collection.TestCollection)
       [2020/02/18 13:04:07.390] ----------------------------------------------------------------------
       [2020/02/18 13:04:07.390] Traceback (most recent call last):
       [2020/02/18 13:04:07.390]   File "/data/mci/a9ce976169b1b17dbdbd76e71e079e24/src/test/test_collection.py", line 244, in test_create_index
       [2020/02/18 13:04:07.390]     db.test.drop_indexes()
       [2020/02/18 13:04:07.390]   File "/data/mci/a9ce976169b1b17dbdbd76e71e079e24/src/pymongo/collection.py", line 2060, in drop_indexes
       [2020/02/18 13:04:07.390]     self.drop_index("*", session=session, **kwargs)
       [2020/02/18 13:04:07.390]   File "/data/mci/a9ce976169b1b17dbdbd76e71e079e24/src/pymongo/collection.py", line 2116, in drop_index
       [2020/02/18 13:04:07.390]     session=session)
       [2020/02/18 13:04:07.390]   File "/data/mci/a9ce976169b1b17dbdbd76e71e079e24/src/pymongo/collection.py", line 250, in _command
       [2020/02/18 13:04:07.390]     user_fields=user_fields)
       [2020/02/18 13:04:07.390]   File "/data/mci/a9ce976169b1b17dbdbd76e71e079e24/src/pymongo/pool.py", line 615, in command
       [2020/02/18 13:04:07.390]     user_fields=user_fields)
       [2020/02/18 13:04:07.390]   File "/data/mci/a9ce976169b1b17dbdbd76e71e079e24/src/pymongo/network.py", line 154, in command
       [2020/02/18 13:04:07.390]     parse_write_concern_error=parse_write_concern_error)
       [2020/02/18 13:04:07.390]   File "/data/mci/a9ce976169b1b17dbdbd76e71e079e24/src/pymongo/helpers.py", line 159, in _check_command_response
       [2020/02/18 13:04:07.390]     raise OperationFailure(msg % errmsg, code, response)
       [2020/02/18 13:04:07.390] OperationFailure: ns not found pymongo_test.test
       [2020/02/18 13:04:07.391] ======================================================================
       [2020/02/18 13:04:07.395] ERROR [0.007s]: test_create_indexes (test_collection.TestCollection)
       ...
       [2020/02/18 13:04:07.399] ERROR [0.006s]: test_drop_index (test_collection.TestCollection)
       ...
       [2020/02/18 13:04:07.402] ERROR [0.005s]: test_drop_indexes_non_existent (test_collection.TestCollection)
       ...
       [2020/02/18 13:04:07.405] ERROR [0.005s]: test_index_2dsphere (test_collection.TestCollection)
       ...
       [2020/02/18 13:04:07.413] ERROR [0.004s]: test_index_background (test_collection.TestCollection)
       ...
       [2020/02/18 13:04:07.414] ERROR [0.006s]: test_index_geo2d (test_collection.TestCollection)
       ...
       [2020/02/18 13:04:07.416] ERROR [0.004s]: test_index_hashed (test_collection.TestCollection)
       ...
       [2020/02/18 13:04:07.419] ERROR [0.005s]: test_index_sparse (test_collection.TestCollection)
       ...
       [2020/02/18 13:04:07.420] ERROR [0.006s]: test_index_text (test_collection.TestCollection)
       ...
       [2020/02/18 13:04:07.420] ERROR [0.006s]: test_ensure_index (test_legacy_api.TestLegacy)
       ...
      

      We should change these error message checks to use error codes wherever possible.

      Attachments

        Issue Links

          Activity

            People

              shane.harvey@mongodb.com Shane Harvey
              shane.harvey@mongodb.com Shane Harvey
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: