Fix AzureOpenAI keyless auth by deferring credential validation to SDK#2464
Fix AzureOpenAI keyless auth by deferring credential validation to SDK#2464ppon1086 wants to merge 1 commit intoconfident-ai:mainfrom
Conversation
|
@ppon1086 is attempting to deploy a commit to the Confident AI Team on Vercel. A member of the Team first needs to authorize it. |
|
PR author is not in the allowed authors list. |
| azure_deployment=self.deployment_name, | ||
| azure_ad_token_provider=self.azure_ad_token_provider, | ||
| azure_ad_token=azure_ad_token, | ||
| azure_ad_token=self.azure_ad_token_value, |
There was a problem hiding this comment.
Is there a reason we're using self.azure_ad_token_value here and not azure_ad_token_value you created above?
| except Exception: | ||
| azure_ad_token_value = str(self.azure_ad_token) | ||
|
|
||
| if self.azure_ad_token_provider is None: |
There was a problem hiding this comment.
In this block we're following a precedence, we're giving priority to azure_ad_token_provider first, if that doesn't exist we give priority to azure_ad_token over api_key. This allows us to handle the case where a user provides all 3 of these fields (azure_ad_token_provider > azure_ad_token > api_key), since we're already populating api_key_value and azure_ad_token_value which are all being passed to the client below, I'm worried about which one is used by the client in this case? Do you know what happens in this case and if it's safe to do this?
What changed
SecretStrand string credentials consistentlyWhy this is needed
DeepEval currently raises an error when
api_keyis missing or empty forAzureOpenAIModel, even when key-based authentication is intentionally disabled and Azure AD / managed identity is intended. This prevents valid keyless Azure OpenAI configurations from working and causes an early failure before the OpenAI SDK can resolve authentication.This PR removes premature client-side enforcement and defers authentication handling to the official OpenAI/Azure SDK, aligning DeepEval’s behavior with Azure OpenAI’s documented authentication model and avoids false negative configuration errors.
Tests
SecretStrhandlingRelated issue
Fixes #2431