fix(litestar): apply Litestar's request_max_body_size default - #164
Merged
Conversation
Base automatically changed from
docs/deferred-litestar-logging-defects
to
main
August 10, 2026 17:31
Litestar.from_config() passes every AppConfig field explicitly, so the 10 MB default Litestar.__init__ applies never reached a bootstrapped app and every body-reading handler returned 500. Fill the field in _apply_config when it is Empty, leaving a caller's own value (including an explicit None) alone.
The access-logging tests no longer need request_max_body_size on their handler now that the bootstrapper fills the default.
Two independently verified gaps in the declared >=2.9 floor: AppConfig.request_max_body_size, which LitestarBootstrapper._apply_config now reads, was added in litestar 2.13.0 (absent in 2.12.0) -- on an older litestar the attribute access raises AttributeError. Separately, litestar.middleware.ASGIMiddleware, which LitestarOpenTelemetryInstrumentationMiddleware already subclasses, was added in 2.15.0 (absent in 2.13 and 2.14) -- a pre-existing mismatch for anyone on the OTel path with litestar 2.9-2.14. Both confirmed by installing the relevant versions and inspecting their source.
Add a docs/integrations/litestar.md section (modeled on the Prometheus one) explaining that Litestar.from_config() skips the request_max_body_size default, that the bootstrapper fills it when AppConfig leaves it unset, and how to override it (including None for no limit), with a link to the upstream issue. Fix an imprecise sentence in architecture/bootstrappers.md: Litestar's attach thunk wraps _apply_config, it is not _apply_config itself. Strengthen test_litestar_bootstrap_keeps_explicit_request_max_body_size to prove the caller's limit is enforced, not just stored: it now posts an oversized body to a handler and asserts Litestar's actual 413 response, alongside the existing readback of the configured value.
lesnik512
force-pushed
the
fix/litestar-request-max-body-size
branch
from
August 10, 2026 17:32
83ed86b to
77ac3b9
Compare
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.
Stacked on #163, which carries the change file. Review that first, or read this diff alone — it is four commits of code and docs.
LitestarBootstrapperbuilds its app withLitestar.from_config(), which passes everyAppConfigfield explicitly, so the 10 MBrequest_max_body_sizedefault thatLitestar(...)applies never reached the built app. Every handler taking a request body returned500: 'request_max_body_size' set to 'Empty' on all layersunless the caller set the field themselves._apply_confignow fills it when the fieldis Empty; a caller's own value, including an explicitNonefor no limit, is untouched and now proven enforced by a 413 test. A guard test pins the constant against Litestar's own__init__signature default, so an upstream change fails CI instead of drifting.Design and rationale:
planning/changes/2026-08-10.03-litestar-request-max-body-size.md. Upstream: litestar#4296.Also here, both surfaced by review:
litestarextra floor moves from>=2.9to>=2.15.AppConfig.request_max_body_sizewas added in 2.13.0 andlitestar.middleware.ASGIMiddleware— already subclassed by the OTel middleware before this branch — in 2.15.0, both verified by installing those versions. The declared floor was already unsupported.request_max_body_size=1000workaround they were carrying for this defect.Promoted into
architecture/bootstrappers.md, documented indocs/integrations/litestar.md, and added toplanning/releases/1.4.0.md.🤖 Generated with Claude Code