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

Stable API SSL tests fail with "The apiVersion parameter is required, please configure your MongoClient's API version" error

    • Type: Icon: Build Failure Build Failure
    • Resolution: Duplicate
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • Python Drivers
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      Name of Failure:

      test.test_ssl.TestSSL.test_connect_with_ca_bundle, test.test_ssl.TestSSL.test_mongodb_x509_auth,
      test.test_ssl.TestSSL.test_tlsCRLFile_support,
      test.test_ssl.TestSSL.test_tlsCertificateKeyFilePassword,
      and their async counterparts.

      Link to task:

      https://spruce.mongodb.com/task/mongo_python_driver_stable_api_require_v1_rhel8_auth_test_latest_python3.11_auth_ssl_sharded_cluster_patch_e2e673edeb711e24d7feb620e7552a2a7af2f0b0_680913f2c7ee9c000741f853_25_04_23_16_23_25?execution=0&sortBy=STATUS&sortDir=ASC

      Context of when and why the failure occurred:

      Stack trace:

       [2025/04/23 09:55:45.632] FAILURE: pymongo.errors.ServerSelectionTimeoutError: The apiVersion parameter is required, please configure your MongoClient's API version, full error: {'ok': 0.0, 'errmsg': "The apiVersion parameter is required, please configure your MongoClient's API version", 'code': 498870, 'codeName': 'Location498870', '$clusterTime': {'clusterTime': Timestamp(1745427229, 51), 'signature': {'hash': b'1x\x0f\xbb=\x07\nzn\x92?\x8a\xe7M\xac\xd1X;\x93\xf7', 'keyId': 7496545616198107162}}, 'operationTime': Timestamp(1745427229, 51)}, Timeout: 5.0s, Topology Description: <TopologyDescription id: 68091b1e077e62356f002d0f, topology_type: Unknown, servers: [<ServerDescription ('localhost', 27017) server_type: Unknown, rtt: None, error=OperationFailure('The apiVersion parameter is required, please configure your MongoClient\'s API version, full error: {\'ok\': 0.0, \'errmsg\': "The apiVersion parameter is required, please configure your MongoClient\'s API version", \'code\': 498870, \'codeName\': \'Location498870\', \'$clusterTime\': {\'clusterTime\': Timestamp(1745427229, 51), \'signature\': {\'hash\': b\'1x\\x0f\\xbb=\\x07\\nzn\\x92?\\x8a\\xe7M\\xac\\xd1X;\\x93\\xf7\', \'keyId\': 7496545616198107162}}, \'operationTime\': Timestamp(1745427229, 51)}')>]> ()
       [2025/04/23 09:55:45.632] self = <test.test_ssl.TestSSL testMethod=test_tlsCertificateKeyFilePassword>
       [2025/04/23 09:55:45.632]     @client_context.require_tlsCertificateKeyFile
       [2025/04/23 09:55:45.632]     @ignore_deprecations
       [2025/04/23 09:55:45.632]     def test_tlsCertificateKeyFilePassword(self):
       [2025/04/23 09:55:45.632]         # Expects the server to be running with server.pem and ca.pem
       [2025/04/23 09:55:45.632]         #
       [2025/04/23 09:55:45.632]         #   --sslPEMKeyFile=/path/to/pymongo/test/certificates/server.pem
       [2025/04/23 09:55:45.632]         #   --sslCAFile=/path/to/pymongo/test/certificates/ca.pem
       [2025/04/23 09:55:45.632]         if not hasattr(ssl, "SSLContext") and not _ssl.IS_PYOPENSSL:
       [2025/04/23 09:55:45.632]             self.assertRaises(
       [2025/04/23 09:55:45.632]                 ConfigurationError,
       [2025/04/23 09:55:45.632]                 self.simple_client,
       [2025/04/23 09:55:45.632]                 "localhost",
       [2025/04/23 09:55:45.632]                 ssl=True,
       [2025/04/23 09:55:45.632]                 tlsCertificateKeyFile=CLIENT_ENCRYPTED_PEM,
       [2025/04/23 09:55:45.632]                 tlsCertificateKeyFilePassword="qwerty",
       [2025/04/23 09:55:45.632]                 tlsCAFile=CA_PEM,
       [2025/04/23 09:55:45.632]                 serverSelectionTimeoutMS=1000,
       [2025/04/23 09:55:45.632]             )
       [2025/04/23 09:55:45.632]         else:
       [2025/04/23 09:55:45.632] >           connected(
       [2025/04/23 09:55:45.632]                 self.simple_client(
       [2025/04/23 09:55:45.632]                     "localhost",
       [2025/04/23 09:55:45.632]                     ssl=True,
       [2025/04/23 09:55:45.632]                     tlsCertificateKeyFile=CLIENT_ENCRYPTED_PEM,
       [2025/04/23 09:55:45.632]                     tlsCertificateKeyFilePassword="qwerty",
       [2025/04/23 09:55:45.632]                     tlsCAFile=CA_PEM,
       [2025/04/23 09:55:45.632]                     serverSelectionTimeoutMS=5000,
       [2025/04/23 09:55:45.632]                     **self.credentials,  # type: ignore[arg-type]
       [2025/04/23 09:55:45.632]                 )
       [2025/04/23 09:55:45.632]             )
       [2025/04/23 09:55:45.632] test/test_ssl.py:192: 
       [2025/04/23 09:55:45.632] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
       [2025/04/23 09:55:45.632] test/__init__.py:1330: in connected
       [2025/04/23 09:55:45.632]     client.admin.command("ping")  # Force connection.
       [2025/04/23 09:55:45.632] pymongo/_csot.py:119: in csot_wrapper
       [2025/04/23 09:55:45.632]     return func(self, *args, **kwargs)
       [2025/04/23 09:55:45.632] pymongo/synchronous/database.py:926: in command
       [2025/04/23 09:55:45.632]     with self._client._conn_for_reads(read_preference, session, operation=command_name) as (
       [2025/04/23 09:55:45.632] pymongo/synchronous/mongo_client.py:1864: in _conn_for_reads
       [2025/04/23 09:55:45.632]     server = self._select_server(read_preference, session, operation)
       [2025/04/23 09:55:45.632] pymongo/synchronous/mongo_client.py:1812: in _select_server
       [2025/04/23 09:55:45.632]     server = topology.select_server(
       [2025/04/23 09:55:45.632] pymongo/synchronous/topology.py:409: in select_server
       [2025/04/23 09:55:45.632]     server = self._select_server(
       [2025/04/23 09:55:45.632] pymongo/synchronous/topology.py:387: in _select_server
       [2025/04/23 09:55:45.632]     servers = self.select_servers(
       [2025/04/23 09:55:45.632] pymongo/synchronous/topology.py:294: in select_servers
       [2025/04/23 09:55:45.632]     server_descriptions = self._select_servers_loop(
       [2025/04/23 09:55:45.632] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
       [2025/04/23 09:55:45.632] self = <Topology CLOSED <TopologyDescription id: 68091b1e077e62356f002d0f, topology_type: Unknown, servers: [<ServerDescription ('localhost', 27017) server_type: Unknown, rtt: None>]>>
       [2025/04/23 09:55:45.632] selector = Primary(), timeout = 5.0, operation = 'ping', operation_id = None
       [2025/04/23 09:55:45.632] address = None
       [2025/04/23 09:55:45.632]     def _select_servers_loop(
       [2025/04/23 09:55:45.632]         self,
       [2025/04/23 09:55:45.632]         selector: Callable[[Selection], Selection],
       [2025/04/23 09:55:45.632]         timeout: float,
       [2025/04/23 09:55:45.632]         operation: str,
       [2025/04/23 09:55:45.632]         operation_id: Optional[int],
       [2025/04/23 09:55:45.632]         address: Optional[_Address],
       [2025/04/23 09:55:45.632]     ) -> list[ServerDescription]:
       [2025/04/23 09:55:45.632]         """select_servers() guts. Hold the lock when calling this."""
       [2025/04/23 09:55:45.632]         now = time.monotonic()
       [2025/04/23 09:55:45.632]         end_time = now + timeout
       [2025/04/23 09:55:45.632]         logged_waiting = False
       [2025/04/23 09:55:45.632]     
       [2025/04/23 09:55:45.632]         if _SERVER_SELECTION_LOGGER.isEnabledFor(logging.DEBUG):
       [2025/04/23 09:55:45.632]             _debug_log(
       [2025/04/23 09:55:45.632]                 _SERVER_SELECTION_LOGGER,
       [2025/04/23 09:55:45.632]                 message=_ServerSelectionStatusMessage.STARTED,
       [2025/04/23 09:55:45.632]                 selector=selector,
       [2025/04/23 09:55:45.632]                 operation=operation,
       [2025/04/23 09:55:45.632]                 operationId=operation_id,
       [2025/04/23 09:55:45.632]                 topologyDescription=self.description,
       [2025/04/23 09:55:45.632]                 clientId=self.description._topology_settings._topology_id,
       [2025/04/23 09:55:45.632]             )
       [2025/04/23 09:55:45.632]     
       [2025/04/23 09:55:45.632]         server_descriptions = self._description.apply_selector(
       [2025/04/23 09:55:45.632]             selector, address, custom_selector=self._settings.server_selector
       [2025/04/23 09:55:45.632]         )
       [2025/04/23 09:55:45.632]     
       [2025/04/23 09:55:45.632]         while not server_descriptions:
       [2025/04/23 09:55:45.632]             # No suitable servers.
       [2025/04/23 09:55:45.632]             if timeout == 0 or now > end_time:
       [2025/04/23 09:55:45.632]                 if _SERVER_SELECTION_LOGGER.isEnabledFor(logging.DEBUG):
       [2025/04/23 09:55:45.632]                     _debug_log(
       [2025/04/23 09:55:45.632]                         _SERVER_SELECTION_LOGGER,
       [2025/04/23 09:55:45.632]                         message=_ServerSelectionStatusMessage.FAILED,
       [2025/04/23 09:55:45.632]                         selector=selector,
       [2025/04/23 09:55:45.632]                         operation=operation,
       [2025/04/23 09:55:45.632]                         operationId=operation_id,
       [2025/04/23 09:55:45.632]                         topologyDescription=self.description,
       [2025/04/23 09:55:45.632]                         clientId=self.description._topology_settings._topology_id,
       [2025/04/23 09:55:45.632]                         failure=self._error_message(selector),
       [2025/04/23 09:55:45.632]                     )
       [2025/04/23 09:55:45.632] >               raise ServerSelectionTimeoutError(
       [2025/04/23 09:55:45.632]                     f"{self._error_message(selector)}, Timeout: {timeout}s, Topology Description: {self.description!r}"
       [2025/04/23 09:55:45.632]                 )
       [2025/04/23 09:55:45.632] E               pymongo.errors.ServerSelectionTimeoutError: The apiVersion parameter is required, please configure your MongoClient's API version, full error: {'ok': 0.0, 'errmsg': "The apiVersion parameter is required, please configure your MongoClient's API version", 'code': 498870, 'codeName': 'Location498870', '$clusterTime': {'clusterTime': Timestamp(1745427229, 51), 'signature': {'hash': b'1x\x0f\xbb=\x07\nzn\x92?\x8a\xe7M\xac\xd1X;\x93\xf7', 'keyId': 7496545616198107162}}, 'operationTime': Timestamp(1745427229, 51)}, Timeout: 5.0s, Topology Description: <TopologyDescription id: 68091b1e077e62356f002d0f, topology_type: Unknown, servers: [<ServerDescription ('localhost', 27017) server_type: Unknown, rtt: None, error=OperationFailure('The apiVersion parameter is required, please configure your MongoClient\'s API version, full error: {\'ok\': 0.0, \'errmsg\': "The apiVersion parameter is required, please configure your MongoClient\'s API version", \'code\': 498870, \'codeName\': \'Location498870\', \'$clusterTime\': {\'clusterTime\': Timestamp(1745427229, 51), \'signature\': {\'hash\': b\'1x\\x0f\\xbb=\\x07\\nzn\\x92?\\x8a\\xe7M\\xac\\xd1X;\\x93\\xf7\', \'keyId\': 7496545616198107162}}, \'operationTime\': Timestamp(1745427229, 51)}')>]>
       [2025/04/23 09:55:45.632] pymongo/synchronous/topology.py:344: ServerSelectionTimeoutError
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            noah.stapp@mongodb.com Noah Stapp
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: