Skip to content

Add OnboardingBlockingErrorParser bridging clitelem/error_codes into the onboarding blob, Fixes AB#3462876#3122

Open
wzhipan wants to merge 11 commits into
devfrom
zhipan/onboarding-telemetry-clitelem-v2
Open

Add OnboardingBlockingErrorParser bridging clitelem/error_codes into the onboarding blob, Fixes AB#3462876#3122
wzhipan wants to merge 11 commits into
devfrom
zhipan/onboarding-telemetry-clitelem-v2

Conversation

@wzhipan
Copy link
Copy Markdown
Contributor

@wzhipan wzhipan commented May 18, 2026

C5 in the onboarding telemetry feature series (follows merged #3088 / #3111 / #3117; sibling of #3121 C3).

Adds OnboardingBlockingErrorParser so the onboarding blob captures rich AADSTS / OAuth blocking errors during interactive token requests — not just the small set of WebView ResultCodes OneAuth currently maps to BROKER_INSTALLATION_TRIGGERED / MDM_FLOW.

What this adds:

  • Path A (token response): parse MicrosoftTokenResponse (covers x-ms-clitelem errorCode + sub-error).
  • Path B (authorize response): parse OAuth error_codes parameter — multi-value overload so all listed codes are captured.
  • AADSTS exclusion list for known non-onboarding codes that would otherwise pollute the blob:
    • 50058 (no signed-in user)
    • 50097 (device authentication required — not an onboarding block per se)
    • 50126 (invalid credentials)

Usage: Consumers (OneAuth EmbeddedBrowser, Broker error handler) call OnboardingBlockingErrorParser.parse...() and feed results to OnboardingTelemetryRecorder.addBlockingError(). No callers wired in this PR.

Tests: OnboardingBlockingErrorParserTest (~250 LOC) covers all parse paths, exclusion list, multi-value behavior, and malformed inputs.

Fixes AB#3462876

wzhipan added 4 commits May 18, 2026 10:05
…g blob

Provides a small Kotlin helper that callers (OneAuth navigation fragment,
broker error handler, etc.) can invoke after a failed token request to extract
the eSTS-emitted error code from MicrosoftTokenResponse (which already carries
the parsed x-ms-clitelem header values) and feed it into
OnboardingTelemetryRecorder.addBlockingError(...).

Per design spec §10, position-2 errorCode of the x-ms-clitelem header is the
canonical attribution source for blocking errors. Sub-error code is preferred
when present for finer-grained classification; otherwise falls back to the
top-level error code. Returns null when no error or error is '0'.

Includes 9 unit tests covering both overloads (MicrosoftTokenResponse and raw
header string).
Some 5-digit AADSTS codes look like blocking errors syntactically but are
not onboarding-remediation signals. Excluding them at the policy boundary so
callers don't have to filter individually:

  - 50058 UserInformationNotProvided   (no SSO session - normal sign-in path)
  - 50097 DeviceAuthenticationRequired (in-flow device auth challenge; if WPJ
                                        runs we already record DeviceRegistrationStarted)
  - 50126 InvalidUserNameOrPassword    (wrong credentials - user error)

Filter applies in both extractBlockingError overloads (MicrosoftTokenResponse
and raw x-ms-clitelem header string). Adds 6 new tests covering each excluded
code, sub-error fallthrough behavior, and a sanity check that non-excluded
codes still pass.
eSTS commonly emits multiple AADSTS codes in the OAuth 'error_codes' query
parameter on authorization redirect failures (e.g. '50058,53003' = no SSO
session AND CA-blocked). The single-value overloads return only the
most-specific identifier from the x-ms-clitelem header; for Path B we want
all qualifying codes since the schema's blocking_errors[] is already an array
and callers can invoke addBlockingError once per code.

extractBlockingErrorsFromAuthorizationErrorCodes filters:
- empty entries (trailing commas)
- the literal '0' (eSTS no-error sentinel)
- codes in NON_ONBOARDING_AADSTS_CODES (50058, 50097, 50126)
- duplicates (preserves first-occurrence order)

Adds 10 tests covering null/blank/single/multiple/excluded/all-excluded/
zero-sentinel/empty-entries/whitespace/duplicates cases.
Copilot AI review requested due to automatic review settings May 18, 2026 17:05
@wzhipan wzhipan requested review from a team as code owners May 18, 2026 17:05
@github-actions
Copy link
Copy Markdown

✅ Work item link check complete. Description contains link AB#3462876 to an Azure Boards work item.

2 similar comments
@github-actions
Copy link
Copy Markdown

✅ Work item link check complete. Description contains link AB#3462876 to an Azure Boards work item.

@github-actions
Copy link
Copy Markdown

✅ Work item link check complete. Description contains link AB#3462876 to an Azure Boards work item.

@github-actions
Copy link
Copy Markdown

❌ Work item link check failed. Description contains AB#3462876 but the Bot could not link it to an Azure Boards work item.

Click here to learn more.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Common4j parser utility to convert eSTS-provided “blocking” error signals into onboarding-telemetry-friendly values, enabling richer onboarding attribution from both token responses and authorization redirects.

Changes:

  • Introduces OnboardingBlockingErrorParser to extract blocking errors from MicrosoftTokenResponse (via x-ms-clitelem) and from OAuth error_codes (multi-value).
  • Adds unit tests covering token/header parsing, exclusion filtering, multi-value behavior, and malformed inputs.
  • Updates changelog.txt with a vNext MINOR entry for the new parser.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
common4j/src/main/com/microsoft/identity/common/java/telemetry/OnboardingBlockingErrorParser.kt New parser bridging x-ms-clitelem + OAuth error_codes into onboarding blocking-error strings with filtering.
common4j/src/test/com/microsoft/identity/common/java/telemetry/OnboardingBlockingErrorParserTest.kt Unit tests for the new parser behavior and edge cases.
changelog.txt Adds a vNext entry documenting the new parser feature.

Comment thread changelog.txt
wzhipan added 2 commits May 20, 2026 11:48
- Fix malformed KDoc reference in OnboardingBlockingErrorParser (extra ']' after AbstractMicrosoftStsTokenResponseHandler)
- Align KDoc field names with the actual snake_case blob schema
  (last_blocking_error / blocking_errors) and reference the constants
- Update the attribution precedence docs to match the implementation:
  the parser prefers serverSubErrorCode (most specific) and falls back
  to serverErrorCode, rather than the previous wording that implied
  errorCode was canonical
- Test: rename 'Non-onboarding AADSTS code whitelist' to 'exclusion list'
  to reflect that the codes are being filtered out, not allowed
- Changelog: add PR reference #3122 to the new vNext entry
Copy link
Copy Markdown
Contributor

@Prvnkmr337 Prvnkmr337 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

…metry-clitelem-v2

# Conflicts:
#	changelog.txt
@wzhipan
Copy link
Copy Markdown
Contributor Author

wzhipan commented May 21, 2026

Rebased onto latest dev and resolved changelog conflicts. Please re-review when you get a chance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants