Skip to content

fix(rest): answer extractor rejections with google.rpc.Status - #451

Merged
muscariello merged 1 commit into
stack/11-rest-client-path-encodingfrom
stack/12-rest-rejection-status
Nov 2, 2026
Merged

muscariello merged 1 commit into
stack/11-rest-client-path-encodingfrom
stack/12-rest-rejection-status

Conversation

@muscariello

@muscariello muscariello commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Fixes #425. Replaces #426. Stacked on #450: review only the last commit.

Cause: the HTTP+JSON handlers take input through axum's Json and Query extractors. When one rejects the input (?historyLength=abc, an undecodable body, a missing Content-Type), axum answers before the handler with a plain-text 400, 415 or 422. §11.6 says HTTP+JSON errors use the google.rpc.Status body, which the JSON-RPC router already follows.

Fix: the affected handlers take Result<Json<_>, JsonRejection> or Result<Query<_>, QueryRejection>, and a rejection is answered through rest_payload_error_response: 400 INVALID_ARGUMENT with a BadRequest detail. A body over DefaultBodyLimit keeps axum's 413.

Decision for review: a missing or wrong Content-Type now gives 400 with a Status body instead of a bare 415. #426 offered to keep 415 for that one case.

Tests: one new test hits every touched extractor (bad historyLength, bad pageSize on two routes, truncated bodies on three routes, no Content-Type) and expects 400, application/json and INVALID_ARGUMENT.

Unproven: the failure on main was not run locally. CI is the check.

@codecov

codecov Bot commented Nov 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@muscariello
muscariello force-pushed the stack/12-rest-rejection-status branch 2 times, most recently from 388c1b8 to 5293813 Compare November 2, 2026 12:02
The HTTP+JSON handlers took their input through axum's Json and Query
extractors, so a malformed query, an undecodable body or a missing
Content-Type was answered by axum before the handler, as a plain-text
400/415/422. HTTP+JSON errors use the google.rpc.Status body (§11.6),
as #272 made the JSON-RPC router do. The rejections now go through the
invalid-request-body response the handlers already return; a body over
the size limit keeps its 413.

Signed-off-by: gulldan <[email protected]>
@muscariello
muscariello added this pull request to the merge queue Nov 2, 2026
Merged via the queue into main with commit a52fcd7 Nov 2, 2026
25 checks passed
@muscariello
muscariello deleted the stack/12-rest-rejection-status branch November 2, 2026 17:44
@github-actions github-actions Bot mentioned this pull request Nov 2, 2026
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.

[Bug]: HTTP+JSON answers malformed input with axum's plain-text rejections instead of google.rpc.Status

3 participants