Skip to content

feat: explicit request body limit - #196

Merged
blaipr merged 1 commit into
mainfrom
feat/request-body-limits
Aug 26, 2026
Merged

feat: explicit request body limit#196
blaipr merged 1 commit into
mainfrom
feat/request-body-limits

Conversation

@blaipr

@blaipr blaipr commented Aug 26, 2026

Copy link
Copy Markdown
Member

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 a DefaultBodyLimit layer on the whole router.
  • The 413 carries the standard {"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.
  • Restart-only (it is a router layer, consumed at construction), so it joins RestartOnlySettings and is reported by a reload rather than silently ignored.

Why

A pipeline pushing a large sources.yaml through PUT /api/v1/config (a whole directory is one body) hit an undocumented limit with an unexplained empty-ish 413. Now the limit is visible in config.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_bytes and the limit; an in-limit write on the same app still lands.

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
blaipr force-pushed the feat/request-body-limits branch from 4e88f82 to 69d2819 Compare August 26, 2026 11:56
@blaipr
blaipr merged commit 77d7cc2 into main Aug 26, 2026
6 checks passed
@blaipr
blaipr deleted the feat/request-body-limits branch August 26, 2026 12:01
@blaipr blaipr mentioned this pull request Aug 26, 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.

1 participant