fix(tests): isolate credential pool routing tests from real ~/.claude/.credentials.json - #75265
Closed
JonthanaHanh wants to merge 1 commit into
Closed
JonthanaHanh wants to merge 1 commit into
JonthanaHanh wants to merge 1 commit into
Conversation
…/.credentials.json
TestFailureAttribution._make_pool() calls load_pool("anthropic") which
triggers auto-discovery of real Claude Code credentials from
~/.claude/.credentials.json on the developer's machine. This changes the
fixture from the intended single-entry pool to a two-entry pool and makes
test_unmatched_key_does_not_retry_only_pool_entry fail.
Monkeypatch read_claude_code_credentials and read_hermes_oauth_credentials
to return None before load_pool(), matching the isolation pattern already
used in test_anthropic_adapter.py.
Fixes NousResearch#75230
1 task
5 tasks
Collaborator
|
Closing with credit: this exact host-credential leak in the |
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.
Summary
TestFailureAttribution._make_pool()callsload_pool("anthropic")which triggers auto-discovery of real Claude Code credentials from~/.claude/.credentials.jsonon the developer's machine. This changes the fixture from the intended single-entry pool to a two-entry pool and makestest_unmatched_key_does_not_retry_only_pool_entryfail withassert True is False.Root Cause
The
_make_poolhelper only overridesHERMES_HOMEvia monkeypatch, butload_pool("anthropic")still runs the auto-discovery path atagent/credential_pool.py:2245which reads~/.claude/.credentials.jsonfrom the real home directory. When a developer has usable Claude Code OAuth credentials, the auto-discovery inserts a secondclaude_codeentry into the pool, turning a single-entry test into a multi-entry test.Fix
Monkeypatch
read_claude_code_credentialsandread_hermes_oauth_credentialsto returnNonebefore callingload_pool(). This matches the isolation pattern already used intests/agent/test_anthropic_adapter.py(lines 235, 256, 278, 298, 318, 359, 367, 403).Test Plan
pytest tests/agent/test_credential_pool_routing.py -q-> 15 passed~/.claude/.credentials.jsonFixes #75230