mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #893] serve/server.py reads POST bodies as empty when sent with Transfer-Encoding: chunked (no Content-Length fallback) — breaks requests through some reverse-proxy/relay agents #392
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#392
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Originally created by @oscar-investmatic on GitHub (Oct 5, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/893
Environment: Linux, engine 0.1.39, IQ2_XS, behind a reverse-proxy relay agent (Model Uplink) that tunnels requests over a WebSocket and re-issues them to the local server without a known
Content-Length, usingTransfer-Encoding: chunkedinstead.Bug: Every POST handler in
serve/server.pyreads the request body the same way:When a client/proxy sends
Transfer-Encoding: chunkedinstead ofContent-Length(valid per RFC 7230, and common for proxies streaming a body of unknown length),Content-Lengthis absent, so this reads0bytes. The JSON body then parses as empty/{}, and the API returns a misleading400 invalid_request_error: "No messages provided"instead of actually seeing the request.Repro (no proxy needed):
Impact: Any reverse proxy, relay, or load balancer that forwards requests without a precomputed
Content-Length(common — many proxies stream the body through before they know its final size) will see every request fail with a confusing "no messages" error, with no indication it's a transport-framing issue.Fix: added a
_read_body()helper to the requestHandlerthat falls back to manually decoding a chunked body (reading<size-hex>\r\n<data>\r\nsegments until the terminating0-size chunk) whenContent-Lengthis missing andTransfer-Encoding: chunkedis present, used indo_POST's main dispatch (covers/v1/chat/completions,/v1/messages, etc.). PR incoming. Three other spots (_control_body,_config_post,_settings) read bodies the same unsafe way and would benefit from the same helper for consistency - left them alone here to keep the fix minimal and scoped to the reported bug.@Niko1221 commented on GitHub (Oct 7, 2026):
Fixed in 0.1.40.2 (with #894): a POST body sent as Transfer-Encoding: chunked is decoded on every route that reads a body, with a 256 MiB cap (413) and a 400 for a malformed body. Content-Length requests are unchanged. Thank you for the report.