Repository navigation
fix(api): cap request body size and bound dev text fields - #567
Merged
Merged
Conversation
MAX_INPUT_LENGTH is checked after the body is read and parsed, so a client could send any amount of JSON before it was refused, and the /dev/tune multipart upload is spooled before its 10 MB check runs (even with the tuner disabled). /dev/phonemize, /dev/generate_from_phonemes and /dev/ssml did not use the InputText limit at all. Add MAX_REQUEST_BODY_MB (default 32, room for the largest valid speech request in escaped JSON and a tune upload). A small ASGI middleware 413s on a larger Content-Length, and counts chunked bodies as they arrive; FastAPI reports a failed body read as its own 400, so the middleware swaps that response for the 413. The three dev text fields now use InputText.
remsky
reviewed
Oct 29, 2026
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.
MAX_INPUT_LENGTH is checked after the body is read and parsed, so a
client could send any amount of JSON before it was refused, and the
/dev/tune multipart upload is spooled before its 10 MB check runs (even
with the tuner disabled). /dev/phonemize, /dev/generate_from_phonemes
and /dev/ssml did not use the InputText limit at all.
Add MAX_REQUEST_BODY_MB (default 32, room for the largest valid speech
request in escaped JSON and a tune upload). A small ASGI middleware
413s on a larger Content-Length, and counts chunked bodies as they
arrive; FastAPI reports a failed body read as its own 400, so the
middleware swaps that response for the 413. The three dev text fields
now use InputText.
Testing
pytest: new tests, each confirmed to fail without the fix; full suite passes.docker/gpu/Dockerfile.optimizedwith this and six sibling PRs merged.One of seven PRs from the same review. Each is based on master on its own; where they overlap (CHANGELOG
[Unreleased], andkokoro_v1.pyacross the OOM, voice-mix and event-loop PRs), the conflicts are mechanical.