Make Foundry auth overrides replace inherited auth - #1855
Open
sylvesterkaczmarek wants to merge 1 commit into
Open
Make Foundry auth overrides replace inherited auth#1855sylvesterkaczmarek wants to merge 1 commit into
sylvesterkaczmarek wants to merge 1 commit into
Conversation
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
Make Foundry
copy()/with_options()auth overrides replace the inherited authentication method instead of silently keeping both credentials.The current copy implementation resolves auth with truthy fallbacks:
api_key=api_key or self.api_keyazure_ad_token_provider=azure_ad_token_provider or self._azure_ad_token_providerThat means an explicit auth switch does not actually clear the previous method. For example, copying an Azure-AD-authenticated client with
api_key="new-key"retains the inherited token provider, so the explicit API key is not actually used as the clone's auth method.Fix
Treat Foundry authentication as one mutually exclusive choice in both sync and async clients:
ANTHROPIC_FOUNDRY_API_KEYwhen no Azure AD provider was supplied;Regression coverage
Adds sync and async tests for both auth transitions, verifies the actual prepared headers, rejects two explicit auth methods, and verifies an ambient
ANTHROPIC_API_KEYdoes not pollute Azure AD Foundry auth state.The production change is confined to the hand-maintained Foundry client.