Repository navigation
serve: a request body sent gzip or deflate is read decoded; another content coding is a 415 - #1049
Conversation
…ontent coding is a 415 A body with Content-Encoding gzip (or x-gzip) or deflate is decoded before any route reads it, on the generative and decision servers alike. The 64 MiB body limit holds for the bytes sent and again for the decoded body, and decoding stops one byte past it. A body that does not decode, or carries bytes after its stream, is a 400 invalid_request_error that names the coding. Any other coding, or a list of two or more, is a 415 whose Accept-Encoding header names gzip, deflate; it is answered from the head, before 100 Continue. A request that frames no body reads as sent. The decoder is flate2, which the vision crate's PNG reader already links.
There was a problem hiding this comment.
Verdict: CLEAN: Request decoding is bounded, malformed bodies return named errors, and unsupported codings are rejected before body reads.
Checked
Duplicates: 5 new functions, types and constants checked; no duplicate owner found. Dryer reported no pairs.
Complexity: read_body rose 16→21 through coding validation and decode dispatch; keep_alive rose 24→26 through the additional error-status arm. Both keep HTTP policy in its existing owner.
Silent failure: 4 refusal paths followed. Unsupported coding returns 415; decoding, decoded-size and trailing-byte failures return named 400 errors.
Tests: mutation review, not executed. Dropping decoding at http.rs:278, changing > to >= at line 342, or dropping the trailing-byte check at line 348 breaks the new assertions. Unsupported-coding assertions also reject an early 100 Continue. The PR includes FAIL-first output.
Gates: no existing gate, threshold or pin changed.
Escape catalog: no patterns matched.
Adversarial checks: decoded overflow, malformed/trailing streams, repeated coding headers and pipelined-request framing checked against the guards and assertions. Decoding uses only the framed body and request-local state.
Notes
Tests were not rerun. The reported card run lacks the required nvidia-smi line, both compared commit hashes and just gate-* output.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
|
The review is done and the contribution check passed, so I'm merging this. |
압축된 HTTP 요청 body(gzip, deflate)를 풀어서 읽고, 지원하지 않는 content coding은 415로 답합니다.
What and why
A client that sends
Content-Encoding: gzipordeflatetoday gets a 400 "invalid JSON body", because the server parses the compressed bytes as JSON. This PR decodes such a body in the shared HTTP body stage (http::read_body) before any route reads it, so the generation server and the decision server both accept it.gzip(alsox-gzip, including several members) anddeflate(a zlib stream) are decoded.br,zstd) or a list of two or more is a 415 withAccept-Encoding: gzip, deflate, answered from the head before100 Continue.docs/serving.mdlists the new behavior.flate2is already linked intobloomery-servethroughbloomery-vision, so the PR adds no new crate to the build.Release notes: Added: the server reads gzip and deflate encoded request bodies and answers any other content coding with a 415.
Code shape
The review reads these first. A box left unticked needs one line of why.
copying it (
AGENTS.md"Common code first",docs/rust-quality.mdR14). Where I found an existing copy, Inamed it below.
(tensor shapes, the attention kind, the quant). A common owner gained no per-model branch, flag or trait method.
tools/check-comments.sh).cargo fmtandcargo clippyare clean on what I touched; the lint count did not go up.Duplication found or removed (
path:line), or "none": none. Nothing else incrates/decoded a request body or readContent-Encoding.What I ran
The new test
api::tests::compressed_request_bodies_are_read_decodedcovers gzip, a multi-member gzip, chunked gzip, deflate, the limit exactly and one byte past it for both codings, trailing bytes, an undecodable body,br, a coding list, and a bodiless request with aContent-Encodingheader.Before the change (new test on the base server code):
After the change, the serve library and integration tests:
The limit check is guarded from both sides: with
decoded.len() > MAX_BODYchanged to>=, the test fails on the row that decodes to exactly 64 MiB withgzip: body too large: the gzip body decodes past the limit of 67108864 bytes (64 MiB).Real binary on a DGX Spark (GB10, driver 595.84, CUDA 13.3),
bloomery-serve 0.3.11, modelnvidia/Qwen3.8-Flash-Next-FP4-Localatb9ce18a6887e18c089fdea8509a33e63429a3300, started with-m <model folder> --ctx-size 2048. The same chat request is sent plain, gzip and deflate, then three bad requests, then a plain request again:ANSWERSlists the prompt token count (55 for all three) and the visible content. The 16 generated ids all fall inside the reasoning span, so the content is empty and the reasoning text is the same in all three answers.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.