fix(auth): resolve xAI OAuth credentials across profiles - #38440
fix(auth): resolve xAI OAuth credentials across profiles#38440capt-marbles wants to merge 1 commit into
Conversation
|
Verified the credential pool + global store fallback chain. Three things worth noting:
|
dacfed8 to
2fd04f7
Compare
|
Rebased onto current Current head: Validation after rebase: uv run --extra dev pytest \
tests/hermes_cli/test_xai_oauth_profile_auth.py \
tests/hermes_cli/test_auth_xai_oauth_provider.py \
-q
# 85 passed
python3 -m py_compile \
hermes_cli/auth.py \
tests/hermes_cli/test_xai_oauth_profile_auth.py \
tests/hermes_cli/test_auth_xai_oauth_provider.py
git diff --checkNo conflict/merge cleanup needed after the rebase. This is still the same narrow fix: profile-local xAI provider state can be empty while the credential pool or root/global auth store has valid OAuth tokens, and genuinely empty auth still raises |
2fd04f7 to
8d8b9f5
Compare
|
Rebased onto current Current head: Validation after rebase: uv run --extra dev pytest \
tests/hermes_cli/test_xai_oauth_profile_auth.py \
tests/hermes_cli/test_auth_xai_oauth_provider.py \
-q
# 85 passed in 2.98s
python3 -m py_compile \
hermes_cli/auth.py \
tests/hermes_cli/test_xai_oauth_profile_auth.py \
tests/hermes_cli/test_auth_xai_oauth_provider.py
git diff --checkNo conflicts on this rebase. The PR is still the same narrow fix: profile-local xAI provider state can be empty while the credential pool or root/global auth store has valid OAuth tokens, and genuinely empty auth still raises |
|
Thanks for this, @capt-marbles — your fix was correct and is now on Salvaged your commit verbatim (authorship preserved) in #46614 and paired it with the missing write-through half: because xAI rotates the refresh token on every refresh, the read-fallback alone left the global root holding a revoked token whenever a profile refreshed a grant it had read from root — the multi-profile revocation cascade in #43589. #46614 writes the rotated chain back to root in that case, so the cross-profile grant stays coherent in both directions. Closing this in favor of #46614 (merged as 8844e09). Your commit lands on |
Summary
Why
After re-authentication, default/root Hermes could successfully call xAI, but profile/cron contexts could still fail if their provider-local
providers.xai-oauth.tokensstate was empty or stale._read_xai_oauth_tokens()treated that empty singleton as authoritative and raisedxai_auth_missing_access_tokeninstead of checking the credential pool or root auth store.This makes the post-auth failure mode explicit: a user can have valid xAI OAuth credentials available, while cron still behaves as if auth is missing.
Test Plan
python -m pytest tests/hermes_cli/test_xai_oauth_profile_auth.py -q -o 'addopts='produced2 failed, 1 passed; both failures raisedxai_auth_missing_access_tokenwhen usable fallback credentials existed.python -m pytest tests/hermes_cli/test_xai_oauth_profile_auth.py -q -o 'addopts='→3 passed.python -m pytest tests/hermes_cli/test_auth_xai_oauth_provider.py -q -o 'addopts='→82 passed.python -m py_compile hermes_cli/auth.py tests/hermes_cli/test_xai_oauth_profile_auth.py.