Repository navigation
Commit 05392b3
fix(server): reject boolean JSON-RPC request IDs (a2aproject#1350)
# 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](https://www.jsonrpc.org/specification#request_object) 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.
- [x] Follow the `CONTRIBUTING` guide.
- [x] Use a Conventional Commits PR title.
- [x] Ensure tests and linter pass.
- [x] 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 a2aproject#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.
---------
Co-authored-by: mykytanetipa <mykytanetipa@google.com>1 parent ad85806 commit 05392b3
2 files changed
Lines changed: 47 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
236 | | - | |
237 | | - | |
238 | | - | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
239 | 241 | | |
240 | 242 | | |
241 | 243 | | |
| |||
257 | 259 | | |
258 | 260 | | |
259 | 261 | | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
260 | 269 | | |
261 | 270 | | |
262 | 271 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
97 | 132 | | |
98 | 133 | | |
99 | 134 | | |
| |||
0 commit comments