Add runtime support for V2 int64 string-encoded fields#1756
Merged
mbroshi-stripe merged 6 commits intomasterfrom Mar 18, 2026
Merged
Add runtime support for V2 int64 string-encoded fields#1756mbroshi-stripe merged 6 commits intomasterfrom
mbroshi-stripe merged 6 commits intomasterfrom
Conversation
d8449b2 to
054338e
Compare
3176f76 to
cb5ea24
Compare
Member
xavdid-stripe
left a comment
There was a problem hiding this comment.
This makes sense, but will likely conflict with #1762 (at a git and/or logical level). Also I don't think your fancier function actually gets used, so either it's not needed or should be wired up (or I misread)
a7510c6 to
285c24a
Compare
There was a problem hiding this comment.
Pull request overview
Adds runtime coercion for V2 int64_string fields so SDK users can work with native Python int values while V2 JSON wire format uses strings.
Changes:
- Introduces request-side param coercion in
stripe/_encode.pyvia_coerce_v2_params()/_coerce_value()and a shared helper_coerce_int64_string(). - Adds response-side field coercion to
StripeObject._refresh_from()via_field_encodings+_coerce_field_value(). - Adds a dedicated test suite covering request/response coercion scenarios.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
stripe/_encode.py |
Implements request coercion and shared int64_string conversion helper. |
stripe/_stripe_service.py |
Wires request coercion into service request paths via _param_encodings. |
stripe/_stripe_object.py |
Adds response hydration coercion via _field_encodings in _refresh_from. |
tests/test_int64_string.py |
Adds unit tests for both request serialization and response hydration coercion. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
xavdid-stripe
approved these changes
Mar 18, 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.
Why?
V2 APIs represent int64 fields as JSON strings on the wire (e.g.
"12345"instead of12345) to avoid precision loss. The SDK should transparently convert between native Pythonintand this wire format so users don't need to handle string encoding themselves.What?
_coerce_v2_params()and_coerce_value()tostripe/_encode.pyfor request-side coercion (int → str), handling scalars, nested objects, and arrays_field_encodingsclass variable and_coerce_field_value()method toStripeObjectfor response-side coercion (str → int) during_refresh_from