Remove the unnecessary code line because of fix in common#2135
Remove the unnecessary code line because of fix in common#2135Yuki-YuXin wants to merge 27 commits intodevfrom
Conversation
| type: github | ||
| name: AzureAD/microsoft-authentication-library-common-for-android | ||
| ref: dev | ||
| ref: robert/empty-correlation-id-fixes |
There was a problem hiding this comment.
Revert it back before the merge.
There was a problem hiding this comment.
I cannot change the targe branch in the DevOps portal thus change the command here.
| // Set it to a default value. | ||
| .correlationId(DiagnosticContext.INSTANCE.getThreadCorrelationId()) | ||
| // If default value "UNSET", generate a new UUID as correlationId. | ||
| .correlationId(Objects.equals(DiagnosticContext.INSTANCE.getThreadCorrelationId(), "UNSET") ? UUID.randomUUID().toString() : DiagnosticContext.INSTANCE.getThreadCorrelationId()) |
There was a problem hiding this comment.
This logic doesn't belong here. it's the responsibility of DiagnosticContext to generate an ID, and do additional null checks to ensure an actual ID is returned.
There was a problem hiding this comment.
Update the logic inside DiagnosticContext getThreadCorrelationId()
…' into yuki/company-with-robert-PR-test
…ializeDiagnosticContext final String correlationId = StringUti?.isNullOrEmpty(requestCorrelationId)?UUID.randomUUID().toString():requestCorrelationId;
| resultValue = AccountState.createFromAccountResult( | ||
| account = account, | ||
| correlationId = DiagnosticContext.INSTANCE.threadCorrelationId, | ||
| correlationId = "", |
There was a problem hiding this comment.
Could you check what MSAL does here?
There was a problem hiding this comment.
Also, what was your thinking behind changing this from the thread ID to an empty string?
There was a problem hiding this comment.
This path generate AccountState from the SDK cache (authClient.getCurrentAccount())
The default value of DiagnosticContext.INSTANCE.threadCorrelationId is UNSET. And currently, SDK won't transform “UNSET" into UUID.
If use DiagnosticContext.INSTANCE.threadCorrelationId,
- authClient.getCurrentAccount() before signIn. correlation id would be "UNSET"
- signIn. correlation id should be UUID
- authClient.getCurrentAccount() after signIn. When getting correlation id again then becomes UUID as the sign in flow.
I am not sure if the difference between the two correlation ids before and after is what we want
| errorType = ErrorTypes.INVALID_USERNAME, | ||
| errorMessage = "Empty or blank username", | ||
| correlationId = "UNSET" | ||
| correlationId = "" |
There was a problem hiding this comment.
Why not set it at all, meaning the value will be null?
There was a problem hiding this comment.
The correlationId parameter is mandatory. Setting it to “” would be much easier than dealing with if null.
| constructor (parcel: Parcel) : this ( | ||
| account = parcel.serializable<IAccount>() as IAccount, | ||
| correlationId = parcel.readString() ?: "UNSET", | ||
| correlationId = parcel.readString() ?: "", |
There was a problem hiding this comment.
Doesn't UUID.fromString("") also produce an exception?
There was a problem hiding this comment.
That's a good point. How about generating random UUID here?
There was a problem hiding this comment.
Keep the original "UNSET" string.
# Conflicts: # common
… the common PR made changes in getThreadCorrelationId(), if it is null or UNSET, will generate a random UUID
# Conflicts: # common
|
|
||
| val privateCorrelationId = if (correlationId == "UNSET") { UUID.randomUUID().toString() } else { correlationId } | ||
| try { | ||
| UUID.fromString(correlationId) |
There was a problem hiding this comment.
nit: maybe assign the result to a variable and use it in the builder to avoid calling the fromString() method twice
There was a problem hiding this comment.
@Yuki-YuXin let's run the tests without this fix here to ensure it works not. But let's keep this fix here as well, to avoid any production crashes (but clean it up a bit, e.g. call DiagnosticContext.INSTANCE.getThreadCorrelationId() so that a new UUID is generated in there, rather than here at the call site).
There was a problem hiding this comment.
Local GetAccessTokenTests passed with and without the changes here.
# Conflicts: # common
# Conflicts: # common
Company PR: AzureAD/microsoft-authentication-library-common-for-android#2435