diff --git a/doc/changelog.rst b/doc/changelog.rst index 2fd1bdd6b9..09fdeb7622 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -10,9 +10,12 @@ PyMongo 4.14 brings a number of changes including: - Added :meth:`pymongo.asynchronous.mongo_client.AsyncMongoClient.append_metadata` and :meth:`pymongo.mongo_client.MongoClient.append_metadata` to allow instantiated MongoClients to send client metadata on-demand - - Introduces a minor breaking change. When encoding :class:`bson.binary.BinaryVector`, a ``ValueError`` will be raised if the 'padding' metadata field is < 0 or > 7, or non-zero for any type other than PACKED_BIT. +- Fixed a bug that raised ``EncryptionError`` when using :meth:`pymongo.mongo_client.MongoClient.server_info` with an + encrypted connection. :meth:`pymongo.mongo_client.MongoClient.server_info` now runs the camel cased ``buildInfo`` command + instead of the lower cased ``buildinfo`` command which may cause a breaking change in applications that rely on matching the + lower cased ``buildinfo`` command. Changes in Version 4.13.2 (2025/06/17) -------------------------------------- diff --git a/pymongo/asynchronous/database.py b/pymongo/asynchronous/database.py index d0089eb4ee..671ab2b288 100644 --- a/pymongo/asynchronous/database.py +++ b/pymongo/asynchronous/database.py @@ -834,12 +834,12 @@ async def command( Any additional keyword arguments will be added to the final command document before it is sent. - For example, a command like ``{buildinfo: 1}`` can be sent + For example, a command like ``{buildInfo: 1}`` can be sent using: - >>> await db.command("buildinfo") + >>> await db.command("buildInfo") OR - >>> await db.command({"buildinfo": 1}) + >>> await db.command({"buildInfo": 1}) For a command where the value matters, like ``{count: collection_name}`` we can do: diff --git a/pymongo/asynchronous/mongo_client.py b/pymongo/asynchronous/mongo_client.py index 3488030166..18c1e5a456 100644 --- a/pymongo/asynchronous/mongo_client.py +++ b/pymongo/asynchronous/mongo_client.py @@ -2311,7 +2311,7 @@ async def server_info( return cast( dict, await self.admin.command( - "buildinfo", read_preference=ReadPreference.PRIMARY, session=session + "buildInfo", read_preference=ReadPreference.PRIMARY, session=session ), ) diff --git a/pymongo/synchronous/database.py b/pymongo/synchronous/database.py index a11674b9aa..a4c509ac45 100644 --- a/pymongo/synchronous/database.py +++ b/pymongo/synchronous/database.py @@ -834,12 +834,12 @@ def command( Any additional keyword arguments will be added to the final command document before it is sent. - For example, a command like ``{buildinfo: 1}`` can be sent + For example, a command like ``{buildInfo: 1}`` can be sent using: - >>> db.command("buildinfo") + >>> db.command("buildInfo") OR - >>> db.command({"buildinfo": 1}) + >>> db.command({"buildInfo": 1}) For a command where the value matters, like ``{count: collection_name}`` we can do: diff --git a/pymongo/synchronous/mongo_client.py b/pymongo/synchronous/mongo_client.py index 1fd506e052..c72500ae09 100644 --- a/pymongo/synchronous/mongo_client.py +++ b/pymongo/synchronous/mongo_client.py @@ -2303,7 +2303,7 @@ def server_info(self, session: Optional[client_session.ClientSession] = None) -> return cast( dict, self.admin.command( - "buildinfo", read_preference=ReadPreference.PRIMARY, session=session + "buildInfo", read_preference=ReadPreference.PRIMARY, session=session ), ) diff --git a/test/asynchronous/test_database.py b/test/asynchronous/test_database.py index e6f0c6a532..b1406e1568 100644 --- a/test/asynchronous/test_database.py +++ b/test/asynchronous/test_database.py @@ -412,9 +412,9 @@ async def test_validate_collection_background(self): async def test_command(self): self.maxDiff = None db = self.client.admin - first = await db.command("buildinfo") - second = await db.command({"buildinfo": 1}) - third = await db.command("buildinfo", 1) + first = await db.command("buildInfo") + second = await db.command({"buildInfo": 1}) + third = await db.command("buildInfo", 1) self.assertEqualReply(first, second) self.assertEqualReply(second, third) diff --git a/test/mockupdb/test_network_disconnect_primary.py b/test/mockupdb/test_network_disconnect_primary.py index b5ccd5276f..4ab13c5528 100644 --- a/test/mockupdb/test_network_disconnect_primary.py +++ b/test/mockupdb/test_network_disconnect_primary.py @@ -70,8 +70,8 @@ def test_network_disconnect_primary(self): self.assertEqual(TOPOLOGY_TYPE.ReplicaSetWithPrimary, topology.description.topology_type) # Open a socket in the application pool (calls ismaster). - with going(client.db.command, "buildinfo"): - primary.receives("buildinfo").ok() + with going(client.db.command, "buildInfo"): + primary.receives("buildInfo").ok() # The primary hangs replying to ismaster. ismaster_future = Future() @@ -79,8 +79,8 @@ def test_network_disconnect_primary(self): # Network error on application operation. with self.assertRaises(ConnectionFailure): - with going(client.db.command, "buildinfo"): - primary.receives("buildinfo").hangup() + with going(client.db.command, "buildInfo"): + primary.receives("buildInfo").hangup() # Topology type is updated. self.assertEqual(TOPOLOGY_TYPE.ReplicaSetNoPrimary, topology.description.topology_type) @@ -89,9 +89,9 @@ def test_network_disconnect_primary(self): ismaster_future.set_result(primary_response) # Demand a primary. - with going(client.db.command, "buildinfo"): + with going(client.db.command, "buildInfo"): wait_until(lambda: client.primary == primary.address, "rediscover primary") - primary.receives("buildinfo").ok() + primary.receives("buildInfo").ok() self.assertEqual(TOPOLOGY_TYPE.ReplicaSetWithPrimary, topology.description.topology_type) diff --git a/test/mockupdb/test_reset_and_request_check.py b/test/mockupdb/test_reset_and_request_check.py index b438afe894..ab54ce2587 100644 --- a/test/mockupdb/test_reset_and_request_check.py +++ b/test/mockupdb/test_reset_and_request_check.py @@ -89,8 +89,8 @@ def _test_disconnect(self, operation): after = time.time() # Demand a reconnect. - with going(self.client.db.command, "buildinfo"): - self.server.receives("buildinfo").ok() + with going(self.client.db.command, "buildInfo"): + self.server.receives("buildInfo").ok() last = self.ismaster_time self.assertGreaterEqual(last, after, "called ismaster before needed") diff --git a/test/test_database.py b/test/test_database.py index 56691383b2..46bebac204 100644 --- a/test/test_database.py +++ b/test/test_database.py @@ -407,9 +407,9 @@ def test_validate_collection_background(self): def test_command(self): self.maxDiff = None db = self.client.admin - first = db.command("buildinfo") - second = db.command({"buildinfo": 1}) - third = db.command("buildinfo", 1) + first = db.command("buildInfo") + second = db.command({"buildInfo": 1}) + third = db.command("buildInfo", 1) self.assertEqualReply(first, second) self.assertEqualReply(second, third)