fix(auth): add User-Agent header to Qwen OAuth refresh (closes #7746) - #7751
Closed
ten-ltw wants to merge 1 commit into
Closed
fix(auth): add User-Agent header to Qwen OAuth refresh (closes #7746)#7751ten-ltw wants to merge 1 commit into
ten-ltw wants to merge 1 commit into
Conversation
This was referenced Jul 29, 2026
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.
What does this PR do?
Fixes #7746 — Qwen OAuth token refresh silently fails with
invalid JSONbecause the refresh request is missing aUser-Agentheader. The Qwen OAuth server returns a non-JSON response (HTML / redirect) when the header is absent.Root Cause
Reported by @gxmst in issue #7746:
qwen-code-apisendsUser-Agent: QwenCode/0.14.0 (linux; x64)during token refresh and works fine_refresh_qwen_cli_tokens()sends noUser-Agent, causing the OAuth server to return a non-JSON responseresponse.json()on that response and raises a confusinginvalid JSONerrorChanges
hermes_cli/auth.py:
_QWEN_USER_AGENT = "HermesAgent/1.0"constantUser-Agent: HermesAgent/1.0to the httpx.post headers in_refresh_qwen_cli_tokens()qwen_refresh_invalid_jsonerror message to include:tests/hermes_cli/test_auth_qwen_provider.py:
test_refresh_qwen_cli_tokens_sends_user_agent_header: verifies the User-Agent header is sent with the correct valuetest_refresh_qwen_cli_tokens_invalid_json_error_includes_diagnostics: verifies diagnostics are surfaced in the error messageHow to Test
Related Issue
Fixes #7746