Skip to content

Commit 33bbf35

Browse files
pvaneckCopilot
andauthored
[Identity] Improve MI error messages (#43231)
* [Identity] Improve MI error messages For synchronous ManagedIdentityCredential, if a token request is unsuccessful, MSAL will return a dict containing "error" and "error_description" keys. We should ensure that the "error_description" value is in the raised exception. Signed-off-by: Paul Van Eck <[email protected]> * Update sdk/identity/azure-identity/azure/identity/_internal/msal_managed_identity_client.py Co-authored-by: Copilot <[email protected]> --------- Signed-off-by: Paul Van Eck <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent f837589 commit 33bbf35

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

sdk/identity/azure-identity/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
### Other Changes
1212

13+
- Improved error messages from `ManagedIdentityCredential` to include the full error response from managed identity endpoints for better troubleshooting. ([#43231](https://github.com/Azure/azure-sdk-for-python/pull/43231))
14+
1315
## 1.25.0 (2025-09-11)
1416

1517
### Features Added

sdk/identity/azure-identity/azure/identity/_internal/msal_managed_identity_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def _request_token(self, *scopes: str, **kwargs: Any) -> AccessTokenInfo: # pyl
6161
)
6262
error_desc = ""
6363
if result and "error" in result:
64-
error_desc = cast(str, result["error"])
64+
error_desc = f"Token request error: ({result['error']}) {result.get('error_description', '')}"
6565
error_message = self.get_unavailable_message(error_desc)
6666
raise CredentialUnavailableError(error_message)
6767

0 commit comments

Comments
 (0)