PyMongo does not truncate client metadata document to 512 bytes:
>>> from pymongo.driver_info import DriverInfo >>> client = MongoClient(driver=DriverInfo(name='s'*512)) >>> client.admin.command('isMaster') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "pymongo/database.py", line 730, in command read_preference, session) as (sock_info, slave_ok): File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py", line 17, in __enter__ return self.gen.next() File "pymongo/mongo_client.py", line 1301, in _socket_for_reads with self._get_socket(server, session) as sock_info: File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py", line 17, in __enter__ return self.gen.next() File "pymongo/mongo_client.py", line 1223, in _get_socket self.__all_credentials, checkout=exhaust) as sock_info: File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py", line 17, in __enter__ return self.gen.next() File "pymongo/pool.py", line 1126, in get_socket sock_info = self._get_socket_no_auth() File "pymongo/pool.py", line 1178, in _get_socket_no_auth sock_info = self.connect() File "pymongo/pool.py", line 1093, in connect sock_info.ismaster(self.opts.metadata, None) File "pymongo/pool.py", line 516, in ismaster ismaster = IsMaster(self.command('admin', cmd, publish_events=False)) File "pymongo/pool.py", line 614, in command user_fields=user_fields) File "pymongo/network.py", line 167, in command parse_write_concern_error=parse_write_concern_error) File "pymongo/helpers.py", line 159, in _check_command_response raise OperationFailure(msg % errmsg, code, response) pymongo.errors.OperationFailure: The client metadata document must be less then or equal to 512bytes
The handshake spec says:
The entire metadata BSON document MUST NOT exceed 512 bytes. This includes all BSON overhead. The client.application.name cannot exceed 128 bytes. MongoDB will return an error if these limits are not adhered to, which will result in handshake failure. Drivers MUST validate these values and truncate driver provided values if necessary.
- related to
-
PYTHON-1564 Option to extend driver name and version in handshake metadata
- Closed
-
PYTHON-2057 Make 'name' a required argument for DriverInfo class
- Closed
-
PYTHON-4036 Microsoft Semantic Kernel: Add Wrapping Library Metadata to Vector Embeddings Integrations
- Closed
-
PYTHON-3464 Collect FaaS platform information as part of the environment information in driver handshake metadata
- Closed