Repository navigation
fix: reject BigInt in Gemini response decoding - #1521
Conversation
Signed-off-by: Will Killian <[email protected]>
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Recursive checked JSON conversion crates/node/src/convert.rs |
The new conversion recursively processes arrays and object properties. It rejects BigInt values and omits properties whose lookup returns None. |
Response codec integration and validation crates/node/src/types/mod.rs, crates/node/tests/types_tests.mjs |
decode_response now accepts an N-API environment and an untyped JavaScript value, converts the value to JSON, then passes it to the response codec. Tests cover BigInt errors and verify a subsequent valid response decodes. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Sequence Diagram(s)
sequenceDiagram
participant JavaScript
participant GeminiGenerateContentCodec
participant checked_json
participant ResponseCodec
JavaScript->>GeminiGenerateContentCodec: decodeResponse(value)
GeminiGenerateContentCodec->>checked_json: convert JavaScript value
checked_json-->>GeminiGenerateContentCodec: JSON value or pending-exception error
GeminiGenerateContentCodec->>ResponseCodec: decode JSON value
Merge Risk: 
Minimal · up to b9759
-
BigInt responses now produce a catchable error. No issue introduced by this change remains identified before merge.
Pre-merge checks: 
5
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
Overview
Make Gemini
decodeResponsereject JavaScriptBigIntvalues with a catchableTypeErrorinstead of aborting the Node.js process at the napi-rs JSON boundary.Details
BigIntbefore it reaches napi-rs's unimplemented conversion branch. Read each property once so getters cannot bypass the check.Validation:
just test-node: 6 Rust binding tests, 522 JavaScript tests, and 26 plugin-example tests passed.cargo denyfailed on existing lockfile dependencies: RUSTSEC-2026-0391 (zstd), RUSTSEC-2026-0398 and RUSTSEC-2026-0403 (zstd-safe), and RUSTSEC-2026-0410 (zstd-sys). This change does not modify dependencies.Where should the reviewer start?
Start with
checked_jsonincrates/node/src/convert.rs, its use inGeminiGenerateContentCodec::decode_responseincrates/node/src/types/mod.rs, and the subprocess regression incrates/node/tests/types_tests.mjs.Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)
Summary by CodeRabbit
decodeResponsenow reports a clearTypeErrorwhen response values contain BigInt, including in nested data or properties, rather than disrupting the Node.js process.