← Back to Pull requests

fix: reject numeric request ids that are not safe integers #290

Closed
unknown closed this pull request without merging on Oct 14, 2026 11:10 UTC
View on GitHub
unknown unknown commented on Oct 13, 2026 11:21 UTC
Author

Problem

JSON-RPC ids go through JSON.parse, so a numeric id above Number.MAX_SAFE_INTEGER loses precision. {"jsonrpc":"2.0","id":9007199254740993,"method":"tools/list"} got a 200 response with "id":9007199254740992. basic.md says responses MUST include the same ID as the request, and requests MUST include a string or integer ID.

Fix

  • New checkRequestId() in src/handlers.ts: a message whose id is a number that fails Number.isSafeInteger gets -32600 Invalid Request with id: null.

  • POST /mcp returns that error with HTTP 400 before doing any session work.

  • The stdio transport runs the same check before re-serializing the message for inject. Without that, an id like 1e400 would parse to Infinity and JSON.stringify would send it on as null.
  • String ids of any length still work, and so does ±Number.MAX_SAFE_INTEGER.

    Breaking change

    Requests with fractional numeric ids (e.g. 1.5) used to be accepted and are now rejected with -32600 / HTTP 400. The spec requires a string or integer id, so this brings the server in line with it.

    Tests

  • HTTP: the issue's repro returns 400 / -32600 / id: null; a fractional id is rejected; ±MAX_SAFE_INTEGER and a large string id are echoed back unchanged.

  • stdio: the issue's repro and 1e400 both get -32600 with id: null.
  • Fixes #271

    🤖 Generated with Claude Code

    https://claude.ai/code/session_01UF4S3w7iA83V9DVsasLJzM

    Diff: 183 lines (+137 / -46) across 2 files Reviewer: rozzilla Review duration: 1428m
    All Vouch review confidence checks passed
    Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.36 · 183 lines diff across 2 files
    0.36
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.312
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #290"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 35.6% (MEDIUM) · Higher = larger blast radius
    35.6%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 14.1% · Safe to merge
    14.1%