Repository navigation
Preserve Event's own context when fetching and mutating its related object - #2329
Open
jar-stripe wants to merge 3 commits into
Open
jar-stripe wants to merge 3 commits into
jar-stripe wants to merge 3 commits into
Conversation
…bject Event.fetchRelatedObject() used the response getter it was deserialized with directly, so a later no-options mutation on the returned object could pick up whatever default account/context the original client had, instead of the event's own context. EventNotification already avoided this by deserializing with a context-scoped client; give Event the same treatment by adding withStripeContext() to StripeResponseGetter / LiveStripeResponseGetter, and have StripeClient.withStripeContext() delegate to it instead of duplicating the options-cloning logic. Fixes RUN_DEVSDK-3694 (java). Committed-By-Agent: claude
Removed redundant comments about the context scoping.
jar-stripe
marked this pull request as ready for review
November 7, 2026 04:11
jar-stripe
requested review from
mnorth-stripe
and removed request for
a team
November 7, 2026 04:11
jar-stripe
enabled auto-merge (squash)
November 7, 2026 04:11
This branch has not been deployed
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.
Why?
EventNotification.fetchRelatedObject()already deserializes the related object with a context-scoped client (client.withStripeContext(context)), butEvent.fetchRelatedObject()deserialized with the unscoped getter it was originally fetched with. A later no-options mutation on the returned object could therefore pick up whatever default account/context the original client had, instead of the event's own context.What?
withStripeContext(String)toStripeResponseGetter, with an implementation onLiveStripeResponseGetterthat clones the getter's options withstripe_accountcleared andstripe_contextset, regardless of the concreteStripeResponseGetterOptionsimplementation backing itEvent.fetchRelatedObject()to fetch and deserialize the related object through a getter scoped to the event's own context, so any later no-options request on the returned object (e.g. a mutation) is scoped the same wayStripeClient.withStripeContext()to delegate to the newStripeResponseGetter.withStripeContext()instead of duplicating the options-cloning logic inlineSee Also
http://go/j/RUN_DEVSDK-3688
Configuration
skip-changefile: This PR is not a user-facing change, so there's no changefile.