-
fix(hybrid): stream upload to disk and reject negative --max-file-size
发布于
2026-03-27 07:10:27 +00:00 Objective: CodeRabbit flagged two valid issues — unbounded memory read
before size check, and negative values silently treated as unlimited.Approach: Stream upload in 1MB chunks to temp file while checking size
incrementally, so large files never fully load into memory. Add argparse
validator to reject negative --max-file-size values.Evidence: Started the server and tested all scenarios via curl:
Scenario Expected Actual 101MB, no limit (streaming) No 413 ✅ Passed size check (500 from dummy) 101MB, --max-file-size 50 413 ✅ 413: File size exceeds maximum (50MB) 10MB, --max-file-size 50 No 413 ✅ Passed size check --max-file-size -1 Reject ✅ ArgumentTypeError: must be >= 0 Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com
下载附件