Skip to content

Fix initialization of ConfidentialClientApplicationOptions in MergedOptions#3760

Open
cpp11nullptr wants to merge 3 commits intomasterfrom
iepoly/fix-merge-options-concurrency-issue
Open

Fix initialization of ConfidentialClientApplicationOptions in MergedOptions#3760
cpp11nullptr wants to merge 3 commits intomasterfrom
iepoly/fix-merge-options-concurrency-issue

Conversation

@cpp11nullptr
Copy link
Copy Markdown
Contributor

Problem

The ConfidentialClientApplicationOptions property getter in MergedOptions assignes a new empty instance to the backing field, then populated it - allowing a concurrent thread to observe the partially-initialized (empty) object. This caused sporadic "MsalClientException: No ClientId was specified" errors under concurrent GraphServiceClient usage.

Fix

Build and populate the ConfidentialClientApplicationOptions instance in a local variable, then atomically publish it using Interlocked.CompareExchange - this ensures no thread observes an unpopulated instance.

@cpp11nullptr cpp11nullptr requested a review from a team as a code owner March 27, 2026 17:29
@cpp11nullptr
Copy link
Copy Markdown
Contributor Author

Related bug is #3750

Copy link
Copy Markdown
Member

@bgavrilMS bgavrilMS left a comment

Choose a reason for hiding this comment

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

Great fix, thx!

@bgavrilMS bgavrilMS linked an issue Mar 30, 2026 that may be closed by this pull request
@bgavrilMS bgavrilMS added this to the 4.7.0 milestone Mar 30, 2026
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.

Concurrency issue with MergedOptions "No ClientId was specified"

3 participants