fix(tradein/security): photo-upload — чанковое чтение с капом 10MB + Caddy request_body 12MB (#2233) #2258
No reviewers
Labels
No labels
admin
analytics
auth
automation
bug
business
chore
ci
compliance
data
data-moat
docs
duplicate
dx
enhancement
Fable 5 ревью
feedback/max
generative
GG-форсайт
needs-discussion
needs-human
observability
pause-bots
performance
priority/p0
priority/p1
priority/p2
priority/p3
scope/backend
scope/db
scope/devops
scope/frontend
scope/qa
scrapers
security
site-finder
stage/1
stage/2
status/blocked
status/done
status/needs-analysis
status/needs-fix
status/qa
status/ready
status/review
status/wip
tech-debt
tradein
ux
week ревью 1
wontfix
вторичка
ИРД
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lekss361/gendesign#2258
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "fix/tradein-photo-upload-stream-cap"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
trade_in.py::upload_photo:await file.read()(буферизация ВСЕГО тела в RAM до проверки лимита) → чанковое чтение 64KB с капом_MAX_PHOTO_BYTES(10 MiB). 413 бросается СРАЗУ при превышении, остаток тела не вычитывается. Закрывает OOM-вектор приmem_limit: 768m(#2214): multi-GB аплоад больше не может убить backend.>, как раньше), sanitize-путь (Pillow re-encode) получает байт-в-байт тот же вход.request_body { max_size 12MB }scoped на/trade-in/api/*(грубее app-капа, другие маршруты не затронуты).test_upload_photo_streams_over_cap_returns_413_without_full_read: mock UploadFile с бесконечным read + счётчик вызовов — assert 413 и ровно 161 read (кап/64KB+1), т.е. чтение прервалось, а не ушло в бесконечность; INSERT/commit не вызваны.Как проверено
uv run pytest(deselect толькоtest_search_cache_hit): 3021 passed, 6 skipped.Closes #2233