fix request body limits for streamed requests - #33
Conversation
laceyp99
left a comment
There was a problem hiding this comment.
Verified that it orders the reject origins and rate limits before the body limits. Validated myself formatting, linting, and tests pass too. Looks good to me!
Agent PR reviewValidationValidation passed: SummaryPR #33 changes request-safety middleware so Issues and risksNo blocking correctness issues found.
Test coverageThe PR adds focused contract coverage for oversized declared bodies, chunked bodies without I did not rerun the full suite in this read-only review environment. One useful additional edge test would be a mismatched declared length under the limit with actual streamed bytes over the limit, to prove the streamed check catches malicious or incorrect RecommendationLooks safe to continue review. This is an automated review. Please treat it as advisory; human review is still required. |
Review follow-upPushed This strengthens the exact-limit MCP regression test. It now expects the normal Finding 2: intentionally deferredThe The contract tests should remain in place as an upgrade guard. We should revisit an explicit receive-wrapper if a FastAPI/Starlette upgrade breaks them, the API becomes externally exposed or higher traffic, or removing private-framework coupling becomes a specific project goal. |
Summary Changes
MEMORIES_REQUEST_BODY_MAX_BYTESagainst the bytes actually received for REST and MCPPOST/PATCHrequests, including chunked requests withoutContent-Length.Validation
.venv\Scripts\python.exe -m ruff format --check .- passed.venv\Scripts\python.exe -m ruff check .- passed.venv\Scripts\python.exe -m pytest- passed, 134 tests.venv\Scripts\python.exe -m pre_commit run --all-files- passedAdditional Notes
MEMORIES_REQUEST_BODY_MAX_BYTESso downstream FastAPI handlers can consume them.