azure-sdk-for-java icon indicating copy to clipboard operation
azure-sdk-for-java copied to clipboard

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

Open gwimmel opened this issue 1 month ago • 3 comments

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

gwimmel avatar Nov 04 '25 12:11 gwimmel

@gwimmel Thanks for filing the bug. @g2vinay should be able to help you out and provide a fix soon.

samvaity avatar Nov 05 '25 20:11 samvaity

@gwimmel do you have access to the full stack trace ? would be great to see that for reference. I'll look into reproducing this later this week.

g2vinay avatar Nov 12 '25 21:11 g2vinay

@gwimmel do you have access to the full stack trace ? would be great to see that for reference. I'll look into reproducing this later this week.

@g2vinay Thanks. Unfortunately I do not have a stack trace, as it is not included in the log (this is the main problem described above), and I cannot reproduce the error on my local machine.

gwimmel avatar Nov 13 '25 07:11 gwimmel