mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #894] [CLOSED] serve: decode chunked request bodies (fixes empty-body 400 behind some proxies) #2900
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#2900
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?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/894
Author: @oscar-investmatic
Created: 10/5/2026
Status: ❌ Closed
Base:
main← Head:fix/chunked-request-body📝 Commits (10+)
fa16567setup: an earlier config that does not parse is skipped, not a crash; configs are written atomically (#459)749d957setup (--backend hip): a system ROCm without the HIP development files falls back to the wheels (#446)5a30024calibrate: the engine's arguments come from the server's engine_args; a failed tuning says why (#447)9f60d13serve, setup: name the small split card that caps the prompt chunk; setup recommends the big card alone (#448)eb8da1d/metrics: each request's speculative draft counts, and their sums in the totals (#457)6a09387setup (--gguf-dir): GGUFs Strata cannot run are named as such, with the --family/--model to use (#444)d6a91e2docs: the Coder is weaker outside code, Chinese/CJK text included; the unpruned sizes for that (#438)d8d4ad3Merge branch 'f-135-eng' into rel-0.1.357b600d5Merge branch 'f-135-small' into rel-0.1.35d9ab843Engine 0.1.35: Windows AMD uses its bundled HIP runtime (#468 #461), the low-RAM resident mode on Windows 32 GB PCs (#467), fixes #460 #459 #446 #447 #457 #448 #444; setup requires it📊 Changes
1 file changed (+34 additions, -1 deletions)
View changed files
📝
serve/server.py(+34 -1)📄 Description
Fixes #893.
POST handlers in
serve/server.pyread the body viaContent-Lengthonly:A proxy/relay forwarding a request with
Transfer-Encoding: chunkedinstead (noContent-Length— valid per RFC 7230, common when a proxy streams a body of unknown length) gets read as 0 bytes, so the JSON parses empty and the API returns a misleading400 "No messages provided"instead of actually seeing the request. Repro and details in #893.Change: adds a
_read_body()helper on the requestHandlerthat reads viaContent-Lengthas before, or decodes a chunked body (<size-hex>\r\n<data>\r\nsegments until the terminating0-size chunk) whenTransfer-Encoding: chunkedis present instead. Used indo_POST's main dispatch, which covers/v1/chat/completions,/v1/messages, and the other/v1/*routes.Scope: kept minimal/targeted at the reported bug. Three other spots (
_control_bodyfor/unloadand/load,_config_post,_settings) read bodies the same Content-Length-only way and would benefit from the same helper for consistency — left alone here since they're for the local web UI, not the API path that was actually broken; happy to extend this PR to cover them too if maintainers want it in the same change.Testing:
python3 -m py_compile serve/server.pypassesTransfer-Encoding: chunkedrequest to/v1/chat/completionsreturned 400 before this change, 200 after, with an identical response body to the equivalentContent-LengthrequestContent-Length): requests that previously failed 400 now succeed end-to-end🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.