Skip to content

fix(jsonrpc): reject numeric request ids that are not long integers - #27

Open
0xbigapple wants to merge 3 commits into
release_v4.8.3from
fix/jsonrpc-bigint-id
Open

0xbigapple wants to merge 3 commits into
release_v4.8.3from
fix/jsonrpc-bigint-id

Conversation

@0xbigapple

@0xbigapple 0xbigapple commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

What does this PR do?

JsonRpcRequestValidator rejects numeric request ids that are not integer literals within the signed 64-bit range. Such a request is now answered with:

{"jsonrpc":"2.0","error":{"code":-32600,"message":"Invalid Request: numeric id must be an integer literal within the signed 64-bit range"},"id":9223372036854775808}

Why are these changes required?

jsonrpc4j's parseId() reads such ids with asInt() or asDouble(), so the call is executed but the response carries a truncated or rounded id that the client cannot match to its request. jsonrpc4j 1.7 is the latest release and master still has the same code; Rejecting is simpler than restoring the id outside jsonrpc4j, common clients send integer counters or string ids, and the JSON-RPC 2.0 specification says numeric ids SHOULD NOT contain fractional parts.

This PR has been tested by:

  • Unit Tests: JsonRpcServletTest and AdminJsonRpcRequestTest cover rejection with exact echo of out-of-range integers and fractional or exponent ids, in single and batch requests, and keep Long.MAX_VALUE, Long.MIN_VALUE and string ids accepted. The new assertions fail on the current release_v4.8.3 head.
  • Manual Testing

Follow up

None.

Extra details

Breaking change (release-note item): JSON-RPC requests whose numeric id is not an integer literal within [-9223372036854775808, 9223372036854775807] are now rejected with -32600 Invalid Request.

jsonrpc4j parses integral ids beyond the long range with asInt() and
fractional ids with asDouble(), so on the public endpoint a request id
like 9223372036854775808 was executed and answered with id 0, and distinct
ids in a batch collided. Answer an Invalid Request that echoes the original
id instead. The Admin endpoint already echoed such ids unchanged; it now
rejects them too so both entry points share one rule.

The shared request mapper reads floating-point literals as BigDecimal so
the echoed id keeps its value instead of a double approximation.
@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7166e65d-bbec-4fc0-ae7d-f7eef52e3b17

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
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-05T07:03:43.400731Z 0496d6b PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 4 files

View guided diff | Turn on auto-fix | Re-trigger cubic

Echo a rejected fractional id as the parsed double.
BigDecimal parsing throws NumberFormatException on it, which escaped the
parse boundary of the Admin request handler.
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.

1 participant