From 2f7669bcdf30242b3cd779bf9c92b865c192d97c Mon Sep 17 00:00:00 2001 From: Ryan Tan Date: Wed, 14 Feb 2024 14:47:15 -0800 Subject: [PATCH] Add str() guards to request_id before validation --- CHANGELOG.asciidoc | 5 +++-- .../src/main/python/gremlin_python/driver/connection.py | 7 ++++--- .../src/main/python/gremlin_python/driver/serializer.py | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index e886f0a7ae7..786374e579e 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -24,13 +24,14 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima === TinkerPop 3.6.7 (NOT OFFICIALLY RELEASED YET) * Fixed a bug in Gremlin.Net for .NET 8 that led to exceptions: `InvalidOperationException: Enumeration has not started. Call MoveNext.` +* Fixed message requestId serialization in `gremlin-python`. * Improved error message from `JavaTranslator` by including exception source. -* Added missing `short` serialization (`gx:Int16`) to GraphSONV2 and GraphSONV3 in `gremlin-python` +* Added missing `short` serialization (`gx:Int16`) to GraphSONV2 and GraphSONV3 in `gremlin-python`. * Added tests for error handling for GLV's if tx.commit() is called remotely for graphs without transactions support. * Introduced multi-architecture AMD64/ARM64 docker images for gremlin-console. * Fixed bug in `JavaTranslator` where `has(String, null)` could call `has(String, Traversal)` to generate an error. * Fixed issue where server errors weren't being properly parsed when sending bytecode over HTTP. -* Improved bulkset contains check for elements if all elements in bulkset are of the same type +* Improved bulkset contains check for elements if all elements in bulkset are of the same type. * Fixed bug in `EarlyLimitStrategy` which was too aggressive when promoting `limit()` before `map()`. [[release-3-6-6]] diff --git a/gremlin-python/src/main/python/gremlin_python/driver/connection.py b/gremlin-python/src/main/python/gremlin_python/driver/connection.py index 9641e4e203a..789de181d02 100644 --- a/gremlin-python/src/main/python/gremlin_python/driver/connection.py +++ b/gremlin-python/src/main/python/gremlin_python/driver/connection.py @@ -58,10 +58,11 @@ def close(self): def write(self, request_message): if not self._inited: self.connect() - request_id = str(uuid.uuid4()) if request_message.args.get("requestId"): - request_id = request_message.args.get("requestId") - uuid.UUID(request_id) # Checks for proper UUID or else server will return an error. + request_id = str(request_message.args.get("requestId")) + uuid.UUID(request_id) # Checks for proper UUID or else server will return an error. + else: + request_id = str(uuid.uuid4()) result_set = resultset.ResultSet(queue.Queue(), request_id) self._results[request_id] = result_set # Create write task diff --git a/gremlin-python/src/main/python/gremlin_python/driver/serializer.py b/gremlin-python/src/main/python/gremlin_python/driver/serializer.py index 74ed99523c2..6b522e50b39 100644 --- a/gremlin-python/src/main/python/gremlin_python/driver/serializer.py +++ b/gremlin-python/src/main/python/gremlin_python/driver/serializer.py @@ -240,7 +240,7 @@ def build_message(self, request_id, processor, op, args): def finalize_message(self, message, mime_len, mime_type): ba = bytearray() - request_id = uuid.UUID(message['requestId']) + request_id = uuid.UUID(str(message['requestId'])) ba.extend(self.header_pack(mime_len, mime_type, 0x81, (request_id.int >> 64) & self.max_int64, request_id.int & self.max_int64))