AzureAD / microsoft-authentication-library-for-java

Microsoft Authentication Library (MSAL) for Java http://aka.ms/aadv2
MIT License
289 stars 145 forks source link

[Bug] Exception messages with MI App don't bubble up to the top #768

Closed g2vinay closed 8 months ago

g2vinay commented 10 months ago

Library version used

14.4.2-beta

Java version

JDK 17

Scenario

ManagedIdentityClient - managed identity

Is this a new or an existing app?

None

Issue description and reproduction steps

When the service endpoint returns an error, the source error message is not showing up in the exception stack trace.

Here's the stack trace from cloud shell environment:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See
http://www.slf4j.org/codes.html#StaticLoggerBinder
for further details.
Exception in thread "main" java.util.concurrent.ExecutionException: com.microsoft.aad.msal4j.MsalManagedIdentityException: [Managed Identity] Unexpected exception occurred when parsing the response. See the inner exception for details.
        at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:396)
        at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2073)
        at Test.main(Test.java:103)
Caused by: com.microsoft.aad.msal4j.MsalManagedIdentityException: [Managed Identity] Unexpected exception occurred when parsing the response. See the inner exception for details.
        at com.microsoft.aad.msal4j.AbstractManagedIdentitySource.handleResponse(AbstractManagedIdentitySource.java:101)
        at com.microsoft.aad.msal4j.AbstractManagedIdentitySource.getManagedIdentityResponse(AbstractManagedIdentitySource.java:72)
        at com.microsoft.aad.msal4j.ManagedIdentityClient.getManagedIdentityResponse(ManagedIdentityClient.java:30)
        at com.microsoft.aad.msal4j.AcquireTokenByManagedIdentitySupplier.fetchNewAccessTokenAndSaveToCache(AcquireTokenByManagedIdentitySupplier.java:84)
        at com.microsoft.aad.msal4j.AcquireTokenByManagedIdentitySupplier.execute(AcquireTokenByManagedIdentitySupplier.java:67)
        at com.microsoft.aad.msal4j.AuthenticationResultSupplier.get(AuthenticationResultSupplier.java:69)
        at com.microsoft.aad.msal4j.AuthenticationResultSupplier.get(AuthenticationResultSupplier.java:18)
        at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
        at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)

Relevant code snippets

No response

Expected behavior

The error message from service should be visible in the exception stack trace.

Identity provider

Microsoft Entra ID (Work and School accounts and Personal Microsoft accounts)

Regression

No response

Solution and workarounds

No response

Avery-Dunn commented 8 months ago

Fixed in https://github.com/AzureAD/microsoft-authentication-library-for-java/pull/782 and released in msal4j 1.15.0