fix(auth): skip keychain OAuth injection when harness supplies its own Anthropic credential#17
Closed
vinnie357 wants to merge 1 commit into
Conversation
…n Anthropic credential
Author
|
Superseded by #18, which implements the design-aligned fix: dedup the Anthropic credential at container injection time keyed on the harness-DECLARED env (env() overlays) rather than sniffing ambient process env, plus an explicit per-harness |
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.
When the harness already provides
ANTHROPIC_API_KEYor a non-cloudANTHROPIC_BASE_URL(e.g. omlx/local harnesses pointing athttp://192.168.65.1:8000), awman was still injectingCLAUDE_CODE_OAUTH_TOKENfrom the macOS keychain. Claude Code then sees both and emits "auth may not work", then fails to authenticate.Fix: add
harness_supplies_anthropic_auth(lookup_env)insrc/engine/auth/keychain.rs. When it returnstrue,claude_keychain_credentials()returns an empty vec immediately, before any keychain lookup. Cloud claude harnesses (noANTHROPIC_API_KEY, base URL absent or*.anthropic.com) are unaffected.The guard follows the existing
lookup_env: &dyn Fn(&str) -> Option<String>pattern fromauto_auth_env_overlaysso it is hermetically testable without mutating process-global env state. Five unit tests cover: non-empty API key → true, empty API key → false, non-cloud base URL → true,api.anthropic.com→ false, nothing set → false.Also fixes a pre-existing
clippy::unnecessary_min_or_maxlint insrc/frontend/tui/render.rsthat blockedcargo clippy --all-targets -- -D warnings.