You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Events: stop reading oversized request bodies, and document the size limits #404
Citry's Events endpoints already limit a request in two ways: the body is capped at 1 MiB (an undocumented _max_envelope_bytes setting), and one envelope carries at most 16 calls (payload_too_large). This issue covers what those limits miss.
What is missing
The ASGI adapter reads the whole body into memory before the cap is checked. It should stop reading once the body passes the cap.
The WSGI adapter trusts Content-Length. It should read at most cap + 1 bytes whatever the header says, including a chunked body without one.
The Django adapter reads request.body, which holds up to Django's own 2.5 MB limit in memory, and an upload that middleware parses first has no total limit at all.
The cap is a private, undocumented setting. It should be a documented setting, with bad values rejected.
Form fields are not counted. A small urlencoded body can still hold many short fields.
Uploaded files need no separate limit: Citry's built-in payload codecs do not parse multipart bodies, so a custom codec that builds files reads them from the body, and the body cap bounds the body once every adapter enforces it. On Django, an upload that middleware parsed first is checked against its declared size.
Plan
Setting (in extensions_defaults["events"])
What it limits
Default
_max_body_bytes (renamed from _max_envelope_bytes)
the request body
1 MiB
_max_form_fields
fields in one urlencoded form post
1,000
Both are engine-wide only; a value that is not a positive int raises ValueError when Citry(...) is created.
A request over either limit gets HTTP 413 with the existing code payload_too_large, before parsing (the batch route answers HTTP 200 with the 413 error inside the result envelope, as the protocol requires). On Django, these limits govern event requests in place of DATA_UPLOAD_MAX_MEMORY_SIZE.
Routes tell the host adapters their limit through an optional URLRoute.max_body_bytes callable; the ASGI, WSGI, and Django adapters read at most one byte past it.
Done when
Each adapter has a test that counts the bytes it reads from an oversized body (with a lying Content-Length and with a chunked body without one), the form field limit has a test, both settings are documented in the security guide, and the CHANGELOG has an entry.
changed the title [-]Events: add request size, upload, field and batch-count limits[/-][+]Events: stop reading oversized request bodies, and document the size limits[/+]on Oct 27, 2026
Activity
[-]Events: add request size, upload, field and batch-count limits[/-][+]Events: stop reading oversized request bodies, and document the size limits[/+]fix: stop reading oversized Events request bodies, and document the l…