Skip to content

Wrap unsafe array numbers in RPC responses#2383

Open
samsamtrum wants to merge 1 commit into
Lightprotocol:mainfrom
samsamtrum:fix-array-big-number-wrapping
Open

Wrap unsafe array numbers in RPC responses#2383
samsamtrum wants to merge 1 commit into
Lightprotocol:mainfrom
samsamtrum:fix-array-big-number-wrapping

Conversation

@samsamtrum

Copy link
Copy Markdown

Handle unsafe integer values inside JSON arrays when preprocessing RPC responses.

The existing helper only wrapped large object property values, so unsafe integers in arrays could still be parsed as JavaScript numbers and lose precision.

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (2)
  • js/stateless.js/src/rpc.ts is excluded by none and included by none
  • js/stateless.js/tests/e2e/safe-conversion.test.ts is excluded by none and included by none

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8c9056d4-45eb-4fc5-986f-68166466519c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0e6642f986

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

export function wrapBigNumbersAsStrings(text: string): string {
return text.replace(/(":\s*)(-?\d+)(\s*[},])/g, (match, p1, p2, p3) => {
const num = Number(p2);
return text.replace(/-?\d+(?=\s*[,}\]])/g, (match, offset) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid rewriting numbers inside JSON strings

Because this regex scans the raw JSON text without tracking whether the match is inside a quoted string, it can now rewrite string contents when an unsafe-looking number is preceded by :, [, or , and followed by ], }, or , within that string. For example, a valid RPC string field like {"logs":["Program log: [9007199254740992]"]} becomes invalid JSON after wrapping, so JSON.parse(wrappedJsonString) will throw for responses containing such log/error/message text.

Useful? React with 👍 / 👎.

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.

2 participants