fix(audience): Init does not mutate caller's AudienceConfig (SDK-235)#702
Closed
ImmutableJeffrey wants to merge 3 commits into
Closed
fix(audience): Init does not mutate caller's AudienceConfig (SDK-235)#702ImmutableJeffrey wants to merge 3 commits into
ImmutableJeffrey wants to merge 3 commits into
Conversation
Init auto-fills PersistentDataPath from DefaultPersistentDataPathProvider. The old code wrote that back onto the caller's config object — a surprising side-effect for callers who reuse the config. Clone via MemberwiseClone before the fill-in. Reference-typed properties (OnError, HttpHandler) are intentionally shared — cloning delegates and handlers would break them. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
80be498 to
f8fda34
Compare
Rewrites the Clone() rationale and the Init call-site comment in plain language — no jargon about "shallow copy" or "caller's object". No code changes. All 180 tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
84eb376 to
ba7b793
Compare
The previous order (validate then Clone) reset the compiler's null-flow analysis when config was reassigned to the clone, so the later `new HttpTransport(..., config.PublishableKey, ...)` call emitted CS8604 "Possible null reference argument for parameter 'publishableKey'". Moving the Clone above the PublishableKey check keeps validation on the same config object used downstream. MemberwiseClone is O(1), so the extra allocation on the error path is trivial. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
nattb8
approved these changes
Apr 23, 2026
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.
Summary
AudienceConfig.Clone()backed byMemberwiseClone. Reference-typed properties (OnError,HttpHandler) remain shared — cloning delegates or handlers would break them.Initbefore writing the resolvedPersistentDataPath, so callers who reuse a config (tests, retry flows, domain-reload scenarios) no longer observe a mutated field.Linear: SDK-235