Skip to content

Commit 4b0b533

Browse files
committed
pull the cherrypick
1 parent 25eb7e2 commit 4b0b533

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

common4j/src/main/com/microsoft/identity/common/java/providers/microsoft/microsoftsts/AbstractMicrosoftStsTokenResponseHandler.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ public TokenResult handleTokenResponse(@NonNull final HttpResponse response) thr
111111
}
112112

113113
final String clientDataHeader = response.getHeaderValue(X_MS_CLIENTDATA, 0);
114-
if (!StringUtil.isNullOrEmpty(clientDataHeader)
115-
&& CommonFlightsManager.INSTANCE.getFlightsProvider().isFlightEnabled(CommonFlight.ENABLE_SERVER_CLIENT_DATA_TELEMETRY)) {
114+
if (CommonFlightsManager.INSTANCE.getFlightsProvider().isFlightEnabled(CommonFlight.ENABLE_SERVER_CLIENT_DATA_TELEMETRY)
115+
&& !StringUtil.isNullOrEmpty(clientDataHeader)) {
116116
// eSTS URL-encodes the pipe-delimited value in the response header (e.g. "m%7C0x800482A5%7C%7C...").
117117
// ClientDataInfo.fromPipeDelimited expects an already-decoded value (its contract matches the
118118
// authorize-endpoint path, where UrlUtil#getParameters has already decoded the query param).
@@ -123,6 +123,8 @@ public TokenResult handleTokenResponse(@NonNull final HttpResponse response) thr
123123
} catch (final Exception e) {
124124
// Malformed percent-encoding shouldn't break token parsing; swallow and fall through.
125125
Logger.warn(methodTag, "Failed to URL-decode x-ms-clientdata header: " + e.getMessage());
126+
// Emit that we failed to decode the clientdata value
127+
SpanExtension.current().setAttribute(AttributeName.server_error.name(), "msal_android_decoding_failed");
126128
}
127129
if (decodedClientDataHeader != null) {
128130
final ClientDataInfo clientDataInfo = ClientDataInfo.fromPipeDelimited(decodedClientDataHeader);

common4j/src/main/com/microsoft/identity/common/java/telemetry/ClientDataInfo.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ public static ClientDataInfo fromPipeDelimited(@Nullable final String decodedVal
130130
return info;
131131
} catch (final Exception e) {
132132
Logger.warn(TAG, "Failed to parse clientdata pipe-delimited value: " + e.getMessage());
133+
// Emit that we failed to parse the clientdata value
134+
final Span span = SpanExtension.current();
135+
span.setAttribute(AttributeName.server_error.name(), "msal_android_parsing_failed");
133136
return null;
134137
}
135138
}

0 commit comments

Comments
 (0)