fix(qwen-oauth): add follow_redirects=True and diagnostic logging - #28244
fix(qwen-oauth): add follow_redirects=True and diagnostic logging#28244wjgong001 wants to merge 1 commit into
Conversation
Fixes NousResearch#7746. httpx defaults to follow_redirects=False, so redirect responses from the Qwen OAuth endpoint return empty bodies that fail JSON parsing. Also adds diagnostic logging before JSON parsing to help with future OAuth debugging.
|
Thanks for tracking this down. The underlying bug still appears to exist on current main, but this branch needs narrowing before it is safe to salvage. Problems
Suggested changes
This is an automated hermes-sweeper review; a human maintainer can decide whether to cherry-pick the focused Qwen hunk. |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for tracing the Qwen refresh path. The underlying issue remains present on current main: hermes_cli/auth.py:2294-2306 posts the Qwen refresh request without follow_redirects=True, and hermes_cli/auth.py:2323-2330 then parses the response as JSON.
Problems
- Commit
b14526143353d96359a332356ca33eb6723be449is far broader than this fix: its sole-file diff is+1016/-103inhermes_cli/auth.py, including unrelated Nous, xAI, Azure Foundry, and MiniMax auth changes. Please keep the salvage limited to the Qwen refresh hunk. - There is no regression test for the new request option.
tests/hermes_cli/test_auth_qwen_provider.py:183-200mockshttpx.postbut does not assert its arguments; the PR changes no test files.
Suggested changes
- Retain only the Qwen-specific
follow_redirects=Truechange (and narrowly scoped diagnostics if desired) in_refresh_qwen_cli_tokens. - Add a focused assertion that the refresh call passes
follow_redirects=True, plus diagnostic-path coverage if that logging remains.
This is an automated hermes-sweeper review.
| "client_id": QWEN_OAUTH_CLIENT_ID, | ||
| }, | ||
| timeout=timeout_seconds, | ||
| follow_redirects=True, |
There was a problem hiding this comment.
Please add a focused regression assertion in tests/hermes_cli/test_auth_qwen_provider.py that httpx.post receives follow_redirects=True; the existing success test verifies returned tokens but not the request options.
Summary
Fixes #7746
Root Cause
httpx defaults to
follow_redirects=False(unlikerequestswhich follows by default). The Qwen OAuth token endpoint returns a redirect response (302), which httpx returns as-is — an empty body with no JSON.response.json()then fails with:This explains the same-machine, same-creds asymmetry:
qwen-code-apiusesrequestswhich follows redirects automatically.Changes
follow_redirects=Trueon the httpx.post call — lets httpx follow the redirect and get the actual JSON response from the Qwen OAuth endpointTest Plan
hermes provider auth qwen-oauthagainst a valid Qwen CLI credential file