microsoft-authentication-library-for-android
microsoft-authentication-library-for-android copied to clipboard
NullPointerException on getLastTelemetryHeaderString()
Describe the bug Environment: Production.
in MFA, after entering 8-digit key and receiving a 2-digit number and approved in auth app, expected AuthenticationCallback.onSuccess
, but received AuthenticationCallback.onError
.
Smartphone (please complete the following information):
User A
- Device: SM-S908E (Samsung Galaxy S22 Ultra)
- Android Version: 14
- Screen: [dpi: 600, height: 2932, width: 1440]
- Browser: Chrome Custom Tabs after setting
broker_redirect_uri_registered: false
- MSAL Version: 5.0.0
User B
- Device: Xiaomi POCO F2 Pro
- Android Version: 12
- Screen: [dpi: 440, height: 2270, width: 1080]
- Browser: Chrome Custom Tabs after setting
broker_redirect_uri_registered: false
- MSAL Version: 5.0.0
Stacktrace
Non-fatal Exception: com.microsoft.identity.client.exception.MsalClientException: Attempt to invoke virtual method 'int java.lang.String.hashCode()' on a null object reference
at com.microsoft.identity.client.internal.controllers.MsalExceptionAdapter.msalExceptionFromBaseException(MsalExceptionAdapter.java:53)
at com.microsoft.identity.client.PublicClientApplication$18.onError(PublicClientApplication.java:2204)
at com.microsoft.identity.client.PublicClientApplication$18.onError(PublicClientApplication.java:2195)
at com.microsoft.identity.common.java.controllers.CommandDispatcher.commandCallbackOnError(CommandDispatcher.java:642)
at com.microsoft.identity.common.java.controllers.CommandDispatcher.access$900(CommandDispatcher.java:99)
at com.microsoft.identity.common.java.controllers.CommandDispatcher$4.run(CommandDispatcher.java:622)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:230)
at android.os.Looper.loop(Looper.java:319)
at android.app.ActivityThread.main(ActivityThread.java:8893)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
Caused by com.microsoft.identity.common.java.exception.ClientException: Attempt to invoke virtual method 'int java.lang.String.hashCode()' on a null object reference
at com.microsoft.identity.common.java.controllers.ExceptionAdapter.clientExceptionFromException(ExceptionAdapter.java:390)
at com.microsoft.identity.common.java.controllers.ExceptionAdapter.baseExceptionFromException(ExceptionAdapter.java:349)
at com.microsoft.identity.common.java.controllers.CommandDispatcher.executeCommand(CommandDispatcher.java:547)
at com.microsoft.identity.common.java.controllers.CommandDispatcher.access$100(CommandDispatcher.java:99)
at com.microsoft.identity.common.java.controllers.CommandDispatcher$5.run(CommandDispatcher.java:770)
at io.opentelemetry.context.Context.lambda$wrap$1(Context.java:212)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.hashCode()' on a null object reference
at com.microsoft.identity.common.java.eststelemetry.FailedRequest.hashCode(FailedRequest.java:60)
at java.util.HashMap.hash(HashMap.java:336)
at java.util.HashMap.put(HashMap.java:608)
at java.util.HashSet.add(HashSet.java:220)
at com.microsoft.identity.common.java.eststelemetry.EstsTelemetry.getLastTelemetryHeaderString(EstsTelemetry.java:511)
at com.microsoft.identity.common.java.eststelemetry.EstsTelemetry.getTelemetryHeaders(EstsTelemetry.java:548)
at com.microsoft.identity.common.java.providers.oauth2.OAuth2Strategy.performTokenRequest(OAuth2Strategy.java:217)
at com.microsoft.identity.common.java.providers.microsoft.microsoftsts.MicrosoftStsOAuth2Strategy.performTokenRequest(MicrosoftStsOAuth2Strategy.java:515)
at com.microsoft.identity.common.java.providers.microsoft.microsoftsts.MicrosoftStsOAuth2Strategy.performTokenRequest(MicrosoftStsOAuth2Strategy.java:101)
at com.microsoft.identity.common.java.providers.oauth2.OAuth2Strategy.requestToken(OAuth2Strategy.java:174)
at com.microsoft.identity.common.java.controllers.BaseController.performTokenRequest(BaseController.java:415)
at com.microsoft.identity.common.internal.controllers.LocalMSALController.acquireToken(LocalMSALController.java:172)
at com.microsoft.identity.common.java.commands.InteractiveTokenCommand.execute(InteractiveTokenCommand.java:84)
at com.microsoft.identity.common.java.commands.InteractiveTokenCommand.execute(InteractiveTokenCommand.java:46)
at com.microsoft.identity.common.java.controllers.CommandDispatcher.executeCommand(CommandDispatcher.java:542)
at com.microsoft.identity.common.java.controllers.CommandDispatcher.access$100(CommandDispatcher.java:99)
at com.microsoft.identity.common.java.controllers.CommandDispatcher$5.run(CommandDispatcher.java:770)
at io.opentelemetry.context.Context.lambda$wrap$1(Context.java:212)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)
To Reproduce Steps to reproduce the behavior:
Our Config
{
"client_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"authorization_user_agent": "DEFAULT",
"account_mode": "MULTIPLE",
"broker_redirect_uri_registered": false,
"redirect_uri": "msauth://packagename/[signature]",
"authorities": [{
"type": "AAD",
"audience": {
"type": "AzureADMyOrg",
"tenant_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
}]
}
Invocation
val parameters = AcquireTokenParameters.Builder()
.startAuthorizationFromActivity(requireActivity())
.withScopes(listOf("User.Read"))
.withCallback(authenticationCallback)
.build()
PublicClientApplication
.createMultipleAccountPublicClientApplication(activity.applicationContext, azureConfigFile)
.acquireToken(parameters)
Expected behavior
-
AuthenticationCallback.onSuccess
. - it works fine on some phones that we tested (OnePlus 8T, OnePlus 6T, Samsung S20 FE 5G) but not on the stated phones above.
Actual Behavior
- get
AuthenticationCallback.onError
callback withMsalException(error_code = "unknown_error", message: "Attempt to invoke virtual method 'int java.lang.String.hashCode()' on a null object reference")
What else have we tried
- We have clear data for Chrome app and issue still persist.