Repository navigation
Conversation
GET, PUT and DELETE requests are retried on 500, 502 and 504. When the
retries ran out, urllib3 raised MaxRetryError and requests turned it into
RetryError ("too many 500 error responses"), so ResponseValidation never
saw the response and the server's message was lost. For example,
variable().set("d", {"a": 1}) hid "Graph variable value [{a=1}] ... is
not supported".
Set raise_on_status=False so the last response is returned after the
retries and ResponseValidation raises ServerError with the server's
message, as it already does for POST and for 4xx responses.
bitflicker64
left a comment
There was a problem hiding this comment.
Blocking: no. Score: 9/10. Summary: raise_on_status=False returns the last 5xx response to ResponseValidation, so retried GET, PUT and DELETE raise ServerError with the server message while retry counts and connection errors stay unchanged; the contract test fails on the base with RetryError and passes here.
imbajin
left a comment
There was a problem hiding this comment.
Score: 9.1/10 · Confidence: high
Blocking: no
Summary
The retry policy now returns the final retryable 5xx response to the existing validator, preserving the client ServerError contract and server message.
Evidence
Reviewed the changed Retry configuration, HGraphSession request-to-validator path, VariableManager calls, exact-head CI, and all current PR feedback.
Validation notes
Static source review only; no local live HugeGraph/proxy 502 or 504 reproduction was run.
Purpose of the PR
When the server answers a GET, PUT or DELETE with HTTP 500, the Python client hides the server's message.
client.variable().set("d", {"a": 1})fails withrequests.exceptions.RetryError: HTTPConnectionPool(...): Max retries exceeded with url: /graphspaces/DEFAULT/graphs/hugegraph/variables/d (Caused by ResponseError('too many 500 error responses')). The server's actual answer is "Graph variable value [{a=1}] is of type class java.util.LinkedHashMap is not supported". A list that contains a map behaves the same. I reproduced this onmainand with the releasedhugegraph-python1.7.1 againsthugegraph/hugegraph:latest(server 1.8.0).HGraphSessionretries 500, 502 and 504 through a urllib3Retry, which applies to GET, PUT and DELETE but not POST. When the retries run out, urllib3 raisesMaxRetryErrorby default, and requests turns it intoRetryError.ResponseValidationnever sees the response, so the message it would put intoServerErroris lost, and the caller gets a requests exception instead of the client's own type. POST requests and 4xx answers on the same session already raiseServerErrorwith the server's message. The README says server errors surface through the existing exception types, and the MCP error mapping classifiesServerErrorby that message.Main Changes
The
Retrynow setsraise_on_status=False. The retries happen as before (with the defaultretries=3a PUT that keeps failing is still sent four times, while a POST is sent once), and once they are spent urllib3 returns the last response, whichResponseValidationturns intoServerErrorwith the server's message. The retry-free policy used byTaskManager.wait()is unchanged.Tests:
test_retried_server_errors_raise_the_server_messageruns a local HTTP server that answers every GET, PUT and DELETE with a HugeGraph-style 500 body, and checks that each method raisesServerErrorwith the message after the configured retries (three requests withretries=2). The integration testtest_set_unsupported_value_raises_server_messagestores a map in a graph variable on a live server.Verifying these changes
uv run pytest hugegraph-python-client/src/tests -m "unit or contract": 168 passed, 3 skipped.uv run pytest hugegraph-python-client/src/tests -m "integration and hugegraph": 71 passed againsthugegraph/hugegraph:latest(server 1.8.0).huge_requests.pyreverted, the four new test cases fail with theRetryErrorabove.variable().set()with a map and with a list containing a map getsRetryErroronmainand on 1.7.1, andServerError: Server Exception: Graph variable value [{a=1}] is of type class java.util.LinkedHashMap is not supportedwith this change, after the same 0.6 s of retries.ruff format --check .,ruff check .,ty check hugegraph-python-client/src/pyhugegraphandpython3 scripts/client_api.py --checkpass.hugegraph-mcpselection from its CI job (904 passed) and thehugegraph-llmunit selection (1282 passed, 3 skipped) pass, as they do onmain.I ran everything on Python 3.12 with uv 0.13.6, and only against server 1.8.0, not the 1.7.0 compatibility image. I did not test a 502 or 504 coming from a proxy; those now also raise
ServerErrorwith the proxy's body instead ofRetryError. One caller sees a different type:SchemaManager.run()inhugegraph-llmwrapsRequestExceptionfromget_schema()as "Failed to connect to HugeGraph", so a 500 there now arrives asServerError, the same way a 400 or 404 already does. Connection errors and timeouts are stillRequestException.vermeer-python-clientbuilds the sameRetryand is not changed here.Does this PR potentially affect the following parts?