Skip to content

[BUG] [azure-identity] Stacktrace not logged on error in getToken() call #47155

@gwimmel

Description

@gwimmel

Describe the bug

We observe the following error log in our system:

"Azure Identity => ERROR in getToken() call for scopes [https://ossrdbms-aad.database.windows.net/.default]: Managed Identity authentication failed, see inner exception for more information.", logged by "com.azure.identity.ManagedIdentityCredential".

This issue is not about the error itself, but about the logging of the error such that we can obtain more information for further analysis. The error log references an "inner exception" we cannot see because no stack trace is logged.

To Reproduce
Create a setup such that an error occurs in the getToken() call for scopes; with the available source code that could also be done via unit tests / mocking. See also Additional Context.

Expected behavior
The log entry contains a stack trace with an inner exception.

Setup (please complete the following information):

  • OS: Linux Container (Ubuntu)
  • IDE: IntelliJ
  • Library/Libraries: com.azure:azure-identity:1.17.0 (current version should also be affected)
  • Java version: 21
  • App Server/Environment: Azure Container Apps
  • Frameworks: Spring Boot

Additional context
I looked at the source code and assume the problem is in the logTokenError method of the LoggingUtil class (called by ManagedIdentityCredential as error handling). This method accepts a Throwable error, but logs only its message.
The above mentioned exception "Managed identity authentication failed, see inner exception" is created by the IdentityClientclass.

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • [ x ] Bug Description Added
  • [ x ] Repro Steps Added
  • [ x ] Setup information Added

Metadata

Metadata

Assignees

Labels

Azure.IdentitybugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK team

Type

No type

Projects

Status

Untriaged

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions