diff --git a/changelog b/changelog index 3a94ebf9b..7686aa8b6 100644 --- a/changelog +++ b/changelog @@ -2,6 +2,7 @@ MSAL Wiki : https://github.com/AzureAD/microsoft-authentication-library-for-andr vNext ---------- +- [PATCH] Add check for unset correlation ID when sending Native Auth requests (#2135) Version 5.4.2 --------- diff --git a/msal/src/main/java/com/microsoft/identity/client/internal/CommandParametersAdapter.java b/msal/src/main/java/com/microsoft/identity/client/internal/CommandParametersAdapter.java index 9a76b272a..160a44d1c 100644 --- a/msal/src/main/java/com/microsoft/identity/client/internal/CommandParametersAdapter.java +++ b/msal/src/main/java/com/microsoft/identity/client/internal/CommandParametersAdapter.java @@ -360,7 +360,7 @@ public static SignUpStartCommandParameters createSignUpStartCommandParameters( .challengeType(configuration.getChallengeTypes()) .userAttributes(userAttributes) // Start of the flow, so there is no correlation ID to use from a previous API response. - // Set it to a default value. + // If default value is empty, generate a new UUID as correlationId. .correlationId(DiagnosticContext.INSTANCE.getThreadCorrelationId()) .build(); } @@ -563,7 +563,7 @@ public static SignInStartCommandParameters createSignInStartCommandParameters( .challengeType(configuration.getChallengeTypes()) .scopes(scopes) // Start of the flow, so there is no correlation ID to use from a previous API response. - // Set it to a default value. + // If default value is empty, generate a new UUID as correlationId. .correlationId(DiagnosticContext.INSTANCE.getThreadCorrelationId()) .build(); @@ -792,7 +792,7 @@ public static ResetPasswordStartCommandParameters createResetPasswordStartComman .challengeType(configuration.getChallengeTypes()) .clientId(configuration.getClientId()) // Start of the flow, so there is no correlation ID to use from a previous API response. - // Set it to a default value. + // If default value is empty, generate a new UUID as correlationId. .correlationId(DiagnosticContext.INSTANCE.getThreadCorrelationId()) .build(); diff --git a/msal/src/main/java/com/microsoft/identity/nativeauth/statemachine/states/AccountState.kt b/msal/src/main/java/com/microsoft/identity/nativeauth/statemachine/states/AccountState.kt index 9898aaf50..f930d43a0 100644 --- a/msal/src/main/java/com/microsoft/identity/nativeauth/statemachine/states/AccountState.kt +++ b/msal/src/main/java/com/microsoft/identity/nativeauth/statemachine/states/AccountState.kt @@ -45,6 +45,7 @@ import com.microsoft.identity.common.java.dto.AccountRecord import com.microsoft.identity.common.java.eststelemetry.PublicApiId import com.microsoft.identity.common.java.exception.BaseException import com.microsoft.identity.common.java.exception.ServiceException +import com.microsoft.identity.common.java.logging.DiagnosticContext import com.microsoft.identity.common.java.logging.LogSession import com.microsoft.identity.common.java.logging.Logger import com.microsoft.identity.common.java.result.ILocalAuthenticationResult @@ -309,7 +310,7 @@ class AccountState private constructor( correlationId = correlationId ) - val privateCorrelationId = if (correlationId == "UNSET") { UUID.randomUUID().toString() } else { correlationId } + val privateCorrelationId = if (correlationId == "UNSET") { DiagnosticContext.INSTANCE.getThreadCorrelationId() } else { correlationId } val acquireTokenSilentParameters = AcquireTokenSilentParameters.Builder() .forAccount(currentAccount) @@ -378,6 +379,9 @@ class AccountState private constructor( } } } catch (e: Exception) { + if (e is IllegalArgumentException) { + Logger.error(TAG, "Correlation id is not a valid UUID", e) + } GetAccessTokenError( errorType = ErrorTypes.CLIENT_EXCEPTION, errorMessage = "MSAL client exception occurred in getAccessToken.",