fix(http): enforce body size limits for streamed requests - #32
1 commit merged into
Conversation
Agent PR reviewValidationValidation passed: SummaryThis PR adds streamed request-body size enforcement for Issues and risks
No other blocking correctness issues stood out from the diff. The Starlette version here uses Test coverageThe PR adds useful contract coverage for oversized streamed REST bodies without Important missing coverage: disallowed MCP browser origins with streamed bodies, exact-at-limit bodies, and streamed oversized MCP bodies without Provided review context reports validation passed for RecommendationNeeds changes before merge. This is an automated review. Please treat it as advisory; human review is still required. |
Related Links
Summary
Implemented request body enforcement against actual streamed bytes, so oversized
POST/PATCHbodies are rejected even whenContent-Lengthis absent. Accepted bodies are cached back onto the request so FastAPI can still parse them normally.Files changed
app/request_limits.py: Added streamed body size enforcement and shared413response builder.app/main.py: Runs streamed body enforcement before rate limiting.tests/contract/test_http_contract.py: Added no-Content-Lengthregression coverage and replay validation.tests/contract/test_mcp_http_transport.py: Updated MCP oversized-body coverage.README.md: Updated request body limit documentation.Validation
Ran successfully:
pytestfull suite was attempted but was inconclusive: it hung in this runner. I also verified a minimal no-middleware FastAPITestClientcall hangs in the same environment, so this appears unrelated to the change.Risks
The streamed enforcement buffers valid request bodies up to the configured limit so downstream handlers can parse them. That is bounded by
MEMORIES_REQUEST_BODY_MAX_BYTES.Follow-up
Maintainers should run the normal CI validation in the project’s standard environment, especially full
pytest.Test Steps
ruff format --check .,ruff check ., andpytestOther Notes
This draft PR was created automatically. Human review is required before marking it ready for review or merging.