AzureAD / microsoft-authentication-library-for-java

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

[Bug] Exception Message parsing failure in Azure Linux VM MI. #769

Closed g2vinay closed 9 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. MSAL code fails to parse the exception message with following exception:


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: java.util.MissingFormatArgumentException: Format specifier '%s'
        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: java.util.MissingFormatArgumentException: Format specifier '%s'
        at java.base/java.util.Formatter.format(Formatter.java:2688)
        at java.base/java.util.Formatter.format(Formatter.java:2625)
        at java.base/java.lang.String.format(String.java:4145)
        at com.microsoft.aad.msal4j.IMDSManagedIdentitySource.handleResponse(IMDSManagedIdentitySource.java:123)
        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

No response

Identity provider

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

Regression

No response

Solution and workarounds

No response

Avery-Dunn commented 9 months ago

I believe there was a similar issue found when testing Cloud Shell, and we looked if this formatting issue was anywhere else.

This has already been fixed as part of this PR, and should be in the 1.14.4-beta release: https://github.com/AzureAD/microsoft-authentication-library-for-java/pull/730/files#diff-7f17404b817d43e956ede2bdff75893f897fd1107a413df367733cc0cb60b6c4