Repository navigation
Expose MsalServiceException.ErrorCodesForLogging for diagnostics - #6138
Merged
Neha Bhargava (neha-bhargava) merged 3 commits intoJul 22, 2026
Merged
Conversation
Promote ErrorCodes from internal string[] to a public IReadOnlyList(getter only; setter stays internal) so downstream callers can surface the raw STS error codes (numeric AADSTS codes) for diagnostics and logging. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d296b5aa-33db-4934-a697-cdf1c1999e09
Copilot started reviewing on behalf of
Neha Bhargava (neha-bhargava)
July 21, 2026 20:00
View session
Contributor
There was a problem hiding this comment.
Pull request overview
This PR exposes MsalServiceException.ErrorCodes publicly (as IReadOnlyList) so downstream callers can access raw STS-specific error codes (e.g., numeric AADSTS codes) for diagnostics and logging.
Changes:
- Promoted
MsalServiceException.ErrorCodesfrom an internalstring[]to a publicIReadOnlyList(internal setter) and expanded the XML docs. - Updated
LoggerHelperto use{Count: > 0}pattern matching to accommodate the new list type. - Added PublicAPI baseline entries across TFMs and a changelog entry for the new API.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| CHANGELOG.md | Adds a release note entry for exposing MsalServiceException.ErrorCodes. |
| src/client/Microsoft.Identity.Client/MsalServiceException.cs | Makes ErrorCodes public as IReadOnlyList and updates its documentation. |
| src/client/Microsoft.Identity.Client/Internal/Logger/LoggerHelper.cs | Updates error-codes logging guard from Length to Count. |
| src/client/Microsoft.Identity.Client/PublicApi/netstandard2.0/PublicAPI.Unshipped.txt | Adds the new public API entry for netstandard2.0. |
| src/client/Microsoft.Identity.Client/PublicApi/net8.0/PublicAPI.Unshipped.txt | Adds the new public API entry for net8.0. |
| src/client/Microsoft.Identity.Client/PublicApi/net8.0-ios/PublicAPI.Unshipped.txt | Adds the new public API entry for net8.0-ios. |
| src/client/Microsoft.Identity.Client/PublicApi/net8.0-android/PublicAPI.Unshipped.txt | Adds the new public API entry for net8.0-android. |
| src/client/Microsoft.Identity.Client/PublicApi/net472/PublicAPI.Unshipped.txt | Adds the new public API entry for net472. |
| src/client/Microsoft.Identity.Client/PublicApi/net462/PublicAPI.Unshipped.txt | Adds the new public API entry for net462. |
This was referenced Jul 21, 2026
Bogdan Gavril (bgavrilMS)
approved these changes
Jul 22, 2026
Gladwin Johnson VR (gladjohn)
approved these changes
Jul 22, 2026
… (Bug 3696281) - Rename the new public MsalServiceException.ErrorCodes to ErrorCodesForLogging per PR feedback, matching the sibling SubErrorForLogging and signalling it is a diagnostics-only surface (property is still unshipped, so no break). - Wrap the backing string[] in Array.AsReadOnly so callers cannot downcast the IReadOnlyList and mutate the exception's error codes. - Fix the CHANGELOG placeholder link (#TBD -> #6138) and property name. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d296b5aa-33db-4934-a697-cdf1c1999e09
Copilot started reviewing on behalf of
Neha Bhargava (neha-bhargava)
July 22, 2026 18:02
View session
Copilot started reviewing on behalf of
Neha Bhargava (neha-bhargava)
July 22, 2026 18:21
View session
Travis Walker (trwalke)
approved these changes
Jul 22, 2026
Neha Bhargava (neha-bhargava)
deleted the
nebharg/expose-service-error-codes
branch
July 22, 2026 20:57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Promote
MsalServiceException.ErrorCodesForLoggingfrominternal string[]to a publicIReadOnlyList(getter only; setter stays internal).Why
Downstream diagnostics need the raw STS-specific error codes (numeric
AADSTScodes, e.g.50076,500011) that refineErrorCode. They were already populated internally but not observable by callers.Notes
ErrorCodesForLogging(matchingSubErrorForLogging) to signal it is diagnostics-only; values are service-emitted and may change — not intended for branching production behavior.Array.AsReadOnlyview so callers cannot downcast theIReadOnlyListand mutate the exception's error codes.LoggerHelperupdated ({Length:>0}→{Count:>0}), the only array-specific usage.OTelInstrumentationTestsasserts population + theRawStsErrorCodetelemetry tag.Related
TokenAcquisitionFailureDetails.ServiceErrorCodes, which mirrors this value).