Repository navigation
Preserve event context and clear inherited account scoping - #2329
Merged
Merged
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
zacchua-stripe
left a comment
Contributor
There was a problem hiding this comment.
LGTM! Just had a question about the error thrown by default in StripeResponseGetter
Committed-By-Agent: codex Co-authored-by: codex <noreply@openai.com>
zacchua-stripe
approved these changes
Nov 10, 2026
zacchua-stripe
left a comment
Contributor
There was a problem hiding this comment.
Looks good but wondering if we need a corresponding PR in sdk-codegen?
Contributor
Author
It sure does. Thanks for picking that up! |
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?
Event and notification requests must use the context Stripe returned in the payload. Previously, a notification's initial fetch could inherit the original client's
Stripe-Accountwhile also sending the notification'sStripe-Context, a combination the API rejects with HTTP 400. A related object fetched through a fullEventalso retained the original getter, so later mutations could revert to the client's account/context defaults.Fetching and subsequent object operations now share the event's scope. When a notification has no context, its initial fetch clears the inherited context and account, matching the scope already attached to returned objects on master.
What?
StripeResponseGetterinterface unchanged.Validation
just test: all 2,107 tests passed.just format-checkandgit diff --checkpassed.StripeClientTest.eventFetchedRelatedObjectRetainsContextagainst master (afefabe430b): it fails because the initial GET includesStripe-Account. It passes with this change.See Also
Configuration
skip-changefile: This PR is not a user-facing change, so there's no changefile.