Skip to content

Commit

Permalink
TINKERPOP-3054 Fix requestId Deserialization in gremlin-python (apa…
Browse files Browse the repository at this point in the history
…che#2494)

https://issues.apache.org/jira/browse/TINKERPOP-3054
Added str() guards to request_id before validating to avoid passing UUID into UUID constructor, which is intended to receive a string.
  • Loading branch information
ryn5 authored Feb 29, 2024
1 parent 3166f1b commit 1efe40b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ 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`.
* Fixed bug in bytecode translation of `g.tx().commit()` and `g.tx().rollback()` in all languages.
* 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()`.
* Fixed bug in mid-traversal `mergeE()` where mutations in `sideEffect()` were being applied to the current traverser rather than a `onMatch` edge.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
6 changes: 5 additions & 1 deletion gremlin-python/src/main/python/tests/driver/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,11 @@ def test_client_custom_invalid_request_id_graphbinary_script(client):
assert "badly formed hexadecimal UUID string" in str(ex)


def test_client_custom_valid_request_id_script(client):
def test_client_custom_valid_request_id_script_uuid(client):
assert len(client.submit('g.V()', request_options={"requestId":uuid.uuid4()}).all().result()) == 6


def test_client_custom_valid_request_id_script_string(client):
assert len(client.submit('g.V()', request_options={"requestId":str(uuid.uuid4())}).all().result()) == 6


Expand Down

0 comments on commit 1efe40b

Please sign in to comment.