feat: explicit request body limit - #196
Merged
Merged
Conversation
The limit was always enforced — axum ships a 2 MB default — but silently: nothing declared it, and an oversized push got a bare 413. It is now the server.max_body_bytes config.yaml key (same 2 MiB default, restart-only, reported by a reload like the other router-layer settings), and exceeding it answers 413 with the standard error body naming the key and the limit.
blaipr
force-pushed
the
feat/request-body-limits
branch
from
August 26, 2026 11:56
4e88f82 to
69d2819
Compare
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
server.max_body_bytes(config.yaml, default 2097152 — axum's own 2 MB default, so existing deployments see no behavior change) now names the request body limit that was previously implicit. Applied as aDefaultBodyLimitlayer on the whole router.{"error": ...}body naming the key and the configured limit, via a response mapper — axum's extractor rejection was plain text, unlike every other failure in the API. Safe to rewrite unconditionally: no handler answers 413 itself.RestartOnlySettingsand is reported by a reload rather than silently ignored.Why
A pipeline pushing a large
sources.yamlthroughPUT /api/v1/config(a whole directory is one body) hit an undocumented limit with an unexplained empty-ish 413. Now the limit is visible inconfig.yaml, documented, and the refusal says what to raise.Docs
docs/configuration.md(new key),docs/api.md(errors section),docs/config-api.md(restart-only list + a note on whole-directory pushes).Tests
An app built with a 64-byte limit refuses an oversized host PUT with 413 and a JSON body naming
server.max_body_bytesand the limit; an in-limit write on the same app still lands.