Skip to content

Ignore unset properties of V2 Request param classes when making requests#1796

Merged
prathmesh-stripe merged 5 commits intomasterfrom
prathmesh/fix-request-params-passed-to-v2-api
Feb 23, 2026
Merged

Ignore unset properties of V2 Request param classes when making requests#1796
prathmesh-stripe merged 5 commits intomasterfrom
prathmesh/fix-request-params-passed-to-v2-api

Conversation

@prathmesh-stripe
Copy link
Copy Markdown
Contributor

@prathmesh-stripe prathmesh-stripe commented Feb 20, 2026

Why?

We recently changed behavior of V2 requests in #1788 , #1786 and #1758.
When passing in typed param classes to requests all the properties are set as nil. In V2 this becomes a problem because the backend can accept null value as valid input.
In V1, these null values are removed before being sent to the API which works as expected.

What?

  • Override the object instantiation flow in Ruby in order to track explicitly set keys
  • Ignore the keys that aren't set on the class using the _explicitly_set_keys var.

See Also

https://jira.corp.stripe.com/browse/RUN_DEVSDK-2239

@prathmesh-stripe prathmesh-stripe force-pushed the prathmesh/fix-request-params-passed-to-v2-api branch from d1d550d to 1e08101 Compare February 20, 2026 17:57
@prathmesh-stripe
Copy link
Copy Markdown
Contributor Author

Ensure that set_new_property is set and not ignored by the .to_h.

params = V2Param.new
params = "Something"
params.to_h  # includes the set_new_property

@prathmesh-stripe prathmesh-stripe marked this pull request as ready for review February 20, 2026 21:34
@prathmesh-stripe prathmesh-stripe requested a review from a team as a code owner February 20, 2026 21:34
@prathmesh-stripe prathmesh-stripe requested review from jar-stripe and removed request for a team February 20, 2026 21:34
@prathmesh-stripe prathmesh-stripe changed the title Prathmesh/fix request params passed to v2 api Ignore unset properties of V2 Request param classes when making requests Feb 20, 2026
@prathmesh-stripe prathmesh-stripe enabled auto-merge (squash) February 20, 2026 21:53
Copy link
Copy Markdown
Contributor

@jar-stripe jar-stripe left a comment

Choose a reason for hiding this comment

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

couple comments

@prathmesh-stripe prathmesh-stripe merged commit 611ecf0 into master Feb 23, 2026
15 checks passed
@prathmesh-stripe prathmesh-stripe deleted the prathmesh/fix-request-params-passed-to-v2-api branch February 23, 2026 18:29
xavdid-stripe pushed a commit that referenced this pull request Feb 23, 2026
…sts (#1796)

* Add some tests

* Fixed V2 request param serialization of unset parameters

* Added a test case for updating a property after initialization

---------

Co-authored-by: Michael Broshi <mbroshi@stripe.com>
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.

4 participants