Repository navigation
fix(client): report non-JSON cluster auth errors as RuntimeError - #6310
Merged
qinxuye merged 2 commits intoDec 4, 2026
Merged
Conversation
Client.__init__ checks /v1/cluster/auth and, for a status other than 200 or 404, built its RuntimeError from response.json()['detail']. A plain-text or HTML error (a reverse proxy's 502, an IP allow-list 403) made Client() fail with requests' JSONDecodeError, and a JSON error without "detail" with KeyError, instead of "Failed to get cluster information". Use _get_error_string, as the other client calls and AsyncClient._check_cluster_authenticated do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
qinxuye
reviewed
Dec 4, 2026
qinxuye
left a comment
Contributor
There was a problem hiding this comment.
The focused client suite passed all 124 tests on 44568668. I found one remaining issue in error formatting.
The fallback added in the previous commit used _get_error_string, whose own fallback is str(HTTPError); that text includes the response URL, so Basic Auth credentials embedded in the endpoint ended up in the RuntimeError. Keep the server's JSON detail and otherwise report only the status code and reason. The test now uses an endpoint with credentials and checks that they are absent from the message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
Client(base_url)checksGET /v1/cluster/authin__init__. For a status other than 200 or 404,Client._check_cluster_authenticatedbuilds its error fromresponse.json()['detail']:Client()fail withrequests.exceptions.JSONDecodeError;detailmakes it fail withKeyError: 'detail'.The intended
RuntimeError("Failed to get cluster information, detail: ...")is never raised, so the user sees a JSON parsing error instead of the HTTP status.AsyncClient._check_cluster_authenticatedand the other sync client calls already use_get_error_string(response), which falls back to the HTTP status line.Fix
Use the server's JSON
detailwhen there is one, and otherwise only"<status> <reason>". A JSON error withdetailgives the same message as before. The status-line fallback is formatted directly rather than through_get_error_string, because that helper's own fallback isstr(HTTPError), which includes the request URL and any credentials embedded in it.Tests
xinference/client/tests/test_sync_cluster_auth_error.pystubsrequests.Session.getand buildsClientagainst a 502 HTML page, a plain-text 403, a JSON 500 withoutdetail, and a JSON 403 withdetail. The client is built againsthttp://user:secret@xinference.test. Onmainthe first three fail (JSONDecodeError/KeyError) and the last passes; with this change all 4 raiseRuntimeErrorwith the status line or the server's detail, and the credentials appear in none of them.test_sync_cluster_auth_error.py,test_sync_image_edit_cleanup.py,test_sync_stream_cleanup.py,test_common.py,test_async_error_detail.pyandtest_async_client_cleanup.pyinxinference/client/tests: 124 passed.pre-commit run --from-ref=origin/main --to-ref=HEADpasses.Found by Gemini (through Google Antigravity) while comparing xinference's sync and async Python clients; Claude Code checked it, wrote the fix and the tests.
🤖 Generated with Claude Code