Skip to content

fix: enforce avatar upload size limit before buffering body#220

Merged
chriscarrollsmith merged 2 commits into
mainfrom
fix/216-avatar-upload-size-limit
Jul 2, 2026
Merged

fix: enforce avatar upload size limit before buffering body#220
chriscarrollsmith merged 2 commits into
mainfrom
fix/216-avatar-upload-size-limit

Conversation

@chriscarrollsmith

Copy link
Copy Markdown
Contributor

Summary

  • Reject avatar profile updates when Content-Length exceeds the upload budget before reading the body
  • Stream multipart avatar uploads in 64 KiB chunks and abort once the 2 MB file limit is exceeded
  • Adds unit tests for bounded streaming and content-length checks

Closes #216

Test plan

  • uv run pytest tests/utils/test_images.py tests/routers/core/test_user.py
  • uv run ty check .

Reject oversized Content-Length headers and stream multipart uploads in
fixed-size chunks so workers never hold an entire large file in memory.
Use a thread-backed helper so asyncio.run is not called while pytest
already has an active event loop in CI.
@chriscarrollsmith
chriscarrollsmith merged commit 73cdebe into main Jul 2, 2026
2 checks passed
@chriscarrollsmith
chriscarrollsmith deleted the fix/216-avatar-upload-size-limit branch July 2, 2026 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Security: enforce avatar upload size limit before buffering request body

1 participant