Add runtime support for V2 int64 string-encoded fields#2600
Merged
mbroshi-stripe merged 4 commits intomasterfrom Mar 18, 2026
Merged
Add runtime support for V2 int64 string-encoded fields#2600mbroshi-stripe merged 4 commits intomasterfrom
mbroshi-stripe merged 4 commits intomasterfrom
Conversation
7adfdda to
04d43a7
Compare
04d43a7 to
f22bd2b
Compare
xavdid-stripe
approved these changes
Mar 17, 2026
Member
xavdid-stripe
left a comment
There was a problem hiding this comment.
Looks generally good, but had a few questions
There was a problem hiding this comment.
Pull request overview
This PR adds runtime schema-driven coercion for V2 “int64-as-JSON-string” fields so SDK users can pass native bigint/number inputs while V2 requests are encoded as strings, and V2 responses are decoded back to bigint.
Changes:
- Introduces a runtime schema type (
V2RuntimeSchema) and adds optionalrequestSchema/responseSchemafields toMethodSpec. - Adds
coerceV2RequestData/coerceV2ResponseDataand wires them intoStripeResource._makeRequest()for request/response coercion. - Adds unit + integration tests, plus a mocha setup tweak to allow BigInt values to traverse mocha’s parallel IPC.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tsconfig.cjs.json | Enables es2020.bigint lib types for the CJS TypeScript build. |
| test/setup.js | Adds a global BigInt JSON serialization shim for mocha parallel worker IPC. |
| test/V2Int64Integration.spec.ts | Integration coverage for request/response coercion and JSON-on-the-wire expectations. |
| test/V2Int64.spec.ts | Unit tests for schema-walking coercion functions across objects/arrays/nullables. |
| src/V2Int64.ts | Implements schema-driven coercion for int64_string fields. |
| src/Types.d.ts | Declares V2RuntimeSchema and extends MethodSpec with schema hooks. |
| src/StripeResource.ts | Applies request coercion before serialization and response coercion before returning to callers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4cbb3a2 to
cfbe23b
Compare
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 JS numbers/bigints and this wire format so users don't need to handle string encoding themselves.What?
V2RuntimeSchematype toTypes.d.tsand optionalrequestSchema/responseSchemafields onMethodSpecV2Int64.tswithcoerceV2RequestData(number/bigint → string) andcoerceV2ResponseData(string → bigint) coercion functionsStripeResource._request(): request body is coerced before JSON serialization, response is coerced before returning to callersV2Int64.spec.ts) and integration tests (V2Int64Integration.spec.ts)