Skip to content

fix: reject BigInt in Gemini response decoding - #1521

Merged
willkill07 merged 1 commit into
NVIDIA:mainfrom
willkill07:fix/relay-1137-gemini-bigint
Oct 26, 2026
Merged

willkill07 merged 1 commit into
NVIDIA:mainfrom
willkill07:fix/relay-1137-gemini-bigint

Conversation

@willkill07

@willkill07 willkill07 commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Overview

Make Gemini decodeResponse reject JavaScript BigInt values with a catchable TypeError instead of aborting the Node.js process at the napi-rs JSON boundary.

  • I confirm this contribution is my own work, or I have the right to submit it under this project's license.
  • I searched existing issues and open pull requests, and this does not duplicate existing work.

Details

  • Convert Gemini response input recursively, rejecting BigInt before it reaches napi-rs's unimplemented conversion branch. Read each property once so getters cannot bypass the check.
  • Preserve the TypeScript method signature and document the error behavior.
  • Add a subprocess regression covering top-level and nested values, arrays, and getters, followed by successful decoding of a valid response.
  • No breaking API changes.

Validation:

  • Focused Gemini codec tests: 10 passed.
  • just test-node: 6 Rust binding tests, 522 JavaScript tests, and 26 plugin-example tests passed.
  • Rust formatting, JavaScript formatting, and whitespace checks passed.
  • Staged pre-commit hooks: workspace Clippy/check, hygiene, formatting, and Python/npm audits passed. cargo deny failed 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_json in crates/node/src/convert.rs, its use in GeminiGenerateContentCodec::decode_response in crates/node/src/types/mod.rs, and the subprocess regression in crates/node/tests/types_tests.mjs.

Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

Summary by CodeRabbit

  • Bug Fixes
    • decodeResponse now reports a clear TypeError when response values contain BigInt, including in nested data or properties, rather than disrupting the Node.js process.
    • After a BigInt error, subsequent valid responses can still be decoded successfully. Primitive values and response data without BigInt continue to be handled as before.

@willkill07
willkill07 requested a review from a team as a code owner October 26, 2026 14:08
@github-actions github-actions Bot added size:S PR is small Bug issue describes bug; PR fixes bug lang:js PR changes/introduces Javascript/Typescript code lang:rust PR changes/introduces Rust code labels Oct 26, 2026
@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between af91eee and b975947.

Files selected for processing: 3
  • crates/node/src/convert.rs
  • crates/node/src/types/mod.rs
  • crates/node/tests/types_tests.mjs

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 9 remain after this review.

Recent review details
Context from checks skipped due to timeout: 1
  • GitHub Check: Changes / Detect
Additional context used
Code guidelines: 1
.agents/skills/contribute-integration/SKILL.md — configured
Path-based instructions: 3
Tests should cover the behavior promised by the changed API surface, including error paths and cross-request isolation where relevant.

CodeRabbit configuration file

Files:

  • crates/node/tests/types_tests.mjs
Treat binding changes as public API changes.

CodeRabbit configuration file

Files:

  • crates/node/src/types/mod.rs
  • crates/node/tests/types_tests.mjs
  • crates/node/src/convert.rs
Source excerpt: Keep NeMo Relay optional Source excerpt: Use stable, documented framework or plugin APIs Source excerpt: Wrap tool and LLM paths at the correct framework boundary Source excerpt: Preserve the framework's original behavior wh...

CodeRabbit inference engine (.agents/skills/contribute-integration/SKILL.md)

Files:

  • crates/node/src/types/mod.rs
  • crates/node/tests/types_tests.mjs
  • crates/node/src/convert.rs
Additional comments: 3
crates/node/src/convert.rs: 1

62-95: LGTM!

crates/node/src/types/mod.rs: 1

753-753: LGTM!

Also applies to: 755-760

crates/node/tests/types_tests.mjs: 1

343-374: LGTM!

Walkthrough

decodeResponse now accepts arbitrary JavaScript values and converts them to JSON before response decoding. BigInt values produce a JavaScript TypeError. Tests cover top-level, nested, and getter-property cases, followed by a valid decode.

Changes

Node response conversion

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: Normal

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
Loading
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: Passed 5
Check name Status Explanation
Title check Passed The title follows Conventional Commits format with the allowed lowercase type fix, uses a concise imperative summary, is 46 characters long, and has no trailing period.
Description check Passed The description includes all required sections, completed overview confirmations, implementation details, validation results, reviewer guidance, and a Fixes issue reference.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 3 files.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
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.

@willkill07 willkill07 added this to the 0.11 milestone Oct 26, 2026
@willkill07 willkill07 self-assigned this Oct 26, 2026
@willkill07
willkill07 merged commit 516b979 into NVIDIA:main Oct 26, 2026
51 of 53 checks passed
@willkill07
willkill07 deleted the fix/relay-1137-gemini-bigint branch October 30, 2026 14:46

This branch was previously deployed

1 inactive deployment
fern — b9759472 Deployed Oct 26, 2026 by willkill07 via Clean up docs preview #6576
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug issue describes bug; PR fixes bug lang:js PR changes/introduces Javascript/Typescript code lang:rust PR changes/introduces Rust code size:S PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants