Skip to content

Fix missing stripeContext in RequestOptions.toBuilderFullCopy()#2208

Merged
mbroshi-stripe merged 2 commits intostripe:masterfrom
IamPritamAcharya:fix-requestoptions-stripecontext
Apr 20, 2026
Merged

Fix missing stripeContext in RequestOptions.toBuilderFullCopy()#2208
mbroshi-stripe merged 2 commits intostripe:masterfrom
IamPritamAcharya:fix-requestoptions-stripecontext

Conversation

@IamPritamAcharya
Copy link
Copy Markdown
Contributor

@IamPritamAcharya IamPritamAcharya commented Apr 19, 2026

Why?

RequestOptions.toBuilderFullCopy() does not copy the stripeContext field,
causing it to be lost when rebuilding a RequestOptions instance.

This leads to unexpected behavior where request context metadata is silently dropped.

Before this change:
opts.toBuilderFullCopy().build().getStripeContext() == null

After this change:
opts.toBuilderFullCopy().build().getStripeContext() == original value


What?

  • Added .setStripeContext(this.stripeContext) in toBuilderFullCopy()
  • Added a regression test to ensure stripeContext is preserved during copy

See Also

Changelog

  • Fixes a bug where an existing stripeContext was being reset to null when calling RequestOptions#toBuilderFullCopy()

@IamPritamAcharya IamPritamAcharya requested a review from a team as a code owner April 19, 2026 17:20
@IamPritamAcharya IamPritamAcharya requested review from mbroshi-stripe and removed request for a team April 19, 2026 17:20
Copy link
Copy Markdown
Contributor

@mbroshi-stripe mbroshi-stripe left a comment

Choose a reason for hiding this comment

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

Thanks for catching this and submitting a fix! I left a couple minor comments to address

Comment thread src/test/java/com/stripe/net/RequestOptionsTest.java Outdated
Comment thread src/test/java/com/stripe/net/RequestOptionsTest.java Outdated
Comment thread src/main/java/com/stripe/net/RequestOptions.java
@IamPritamAcharya
Copy link
Copy Markdown
Contributor Author

@mbroshi-stripe
Addressed feedback:

  • Removed redundant test
  • Fixed formatting issues

Thanks for the review!

@mbroshi-stripe mbroshi-stripe enabled auto-merge (squash) April 20, 2026 15:28
@mbroshi-stripe mbroshi-stripe merged commit 684d6ce into stripe:master Apr 20, 2026
11 of 12 checks passed
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.

2 participants