Review report

bitcoin/bitcoin: PR #36758

2 suggestions

Optional improvements

Link

[suggestion] · Malformed id-less requests still disappear inside batches

In the ordinary batch path, malformed id-less JSON-RPC 2.0 objects are suppressed as notifications, while the new singleton assertions require an Invalid Request response.

Location: test/functional/interface_rpc.py:250 (head).

Details and suggested fix

For an authenticated client without a blocking whitelist configuration, {"jsonrpc":"2.0","method":1} now receives HTTP 200 with an Invalid Request error and "id": null when sent alone, but receives HTTP 204 with no body when wrapped in a one-element batch. parse() records V2 and the absent id before rejecting the method. The batch catch constructs the error, but IsNotification() then discards it without checking whether parsing succeeded. This batch behavior predates the PR; the new singleton assertions and existing all-notifications fixture now preserve opposite rules. Suppress batch replies only for successfully parsed notifications, and update the batch fixture plus add a singleton/batch comparison for the same malformed object. No current in-tree production caller producing this input was found; production occurrence is unconfirmed.


Link

[suggestion] · The HTTP-status documentation omits malformed whitelist batches

An authenticated user listed in -rpcwhitelist can still receive HTTP 500 for a valid-JSON batch containing a malformed JSON-RPC 2.0 object, despite the updated HTTP-200 description.

Location: doc/JSON-RPC-interface.md:92 (head).

Details and suggested fix

For example, [{"jsonrpc":"2.0","id":1,"method":1}] reaches the whitelist pre-check, which calls get_str() before jreq.parse() and throws on the numeric method. The outer catch converts this to RPC_PARSE_ERROR; the fresh request still has its default legacy version, so JSONErrorReply returns HTTP 500 and a legacy-shaped error for the whole batch. A missing method follows the same path, while a non-object element produces HTTP 400. This behavior predates the PR and does not bypass authorization or execute the malformed element. Document this whitelist-batch exception alongside the clarified HTTP-status rule rather than implying that valid JSON alone excludes these errors.


Coverage details