Skip to content

fix(server): reject boolean JSON-RPC request IDs - #1350

Open
ningyixi wants to merge 1 commit into
a2aproject:mainfrom
ningyixi:fix/boolean-jsonrpc-request-ids
Open

ningyixi wants to merge 1 commit into
a2aproject:mainfrom
ningyixi:fix/boolean-jsonrpc-request-ids

Conversation

@ningyixi

Copy link
Copy Markdown

Description

JSON-RPC requests with id: true or id: false currently reach the request handler and produce responses containing the same boolean ID. Python's bool satisfies the existing integer check, but JSON-RPC 2.0 distinguishes Boolean from Number and permits only String, Number or Null identifiers.

Reject boolean IDs before dispatch with Invalid Request (-32600) and a null response ID. Add request-level tests for both boolean values and passing controls for integer zero, a positive integer, an empty string and a nonempty string. The invalid requests must not invoke the handler.

  • Follow the CONTRIBUTING guide.
  • Use a Conventional Commits PR title.
  • Ensure tests and linter pass.
  • Update appropriate docs if necessary. No documentation change is needed; this enforces the existing JSON-RPC identifier contract.

No existing issue found for boolean request IDs.

Validation:

  • On the unchanged base, both boolean regressions fail and all four valid-ID controls pass (initial reproduction on Python 3.12).
  • bash scripts/lint.sh: Ruff lint/format and ty pass. ty reports three unused-ignore warnings in unchanged optional gRPC imports.
  • uv run pytest: 2,290 passed, 183 skipped, 3 xfailed and 1 xpassed on the repository-pinned Python 3.10.22.
  • uv run pytest --cov=src --cov-report=term-missing --cov-fail-under=88: same results; 93.29% coverage, exceeding the 88% requirement.
  • git diff --check: passed.

The xfail/xpass cases are marked against #869. Skips include PostgreSQL/MySQL and externally configured multi-server cases. Local HTTP/gRPC and sample integration tests ran as part of the full suite; no live model-provider calls were used.

AI assistance: OpenAI Codex implementation, reproduction and validation.

@ningyixi
ningyixi requested a review from a team as a code owner October 17, 2026 15:32
@github-actions

Copy link
Copy Markdown

🧪 Code Coverage (vs main)

⬇️ Download Full Report

Base PR Delta
src/a2a/server/routes/jsonrpc_dispatcher.py 85.50% 85.71% 🟢 +0.22%
Total 93.14% 93.14% ⚪️ 0.00%

Generated by coverage-comment.yml

This branch has not been deployed

No deployments
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