#1 [high] Finding A (Major): code now depends on validation layer; Invalid→invalid_request beyond #446
helios/src/server/http.rs:124-132 (PR head 2f72e1b):
fn preparation_error(error: Error) -> PreparationError {
match error {
Error::Admission(_) => PreparationError::Failure(error),
Error::Frontend(crate::FrontendError::ImageDecode(_)) => {
PreparationError::Failure(error.admission_context(AdmissionError::Image))
}
other => PreparationError::Http(StatusCode::BAD_REQUEST, other.to_string()),
}
}
Every Error::Admission(_) now goes to Protocol::failure, and helios/src/server.rs:751 maps AdmissionError::Invalid(_) => "invalid_request". Issue #446 (read in full) asks only for context_length_exceeded / unsupported_feature / invalid_grammar / invalid_image; yatesdr's confirming comment lists exactly those four. Invalid is a fifth, much broader class.
Concrete inconsistency, all reachable from request preparation:
"max_tokens": 0→ helios/src/server/request.rs:615-616return Err("output limit must be between 1 and 2147483647 tokens".into());→Error::from(&str)=ExecutionError::State(helios/src/error.rs:174-183) →PreparationError::Http(400)→Protocol::error→"code": "invalid_request_error". Pinned by the PR's own test: helios/src/server/runtime/phase_tests.rs:8737-8759 asserts("invalid_request_error", "invalid_request_error")."stop": [5 strings]→ helios/src/server/stops.rs:63-72Error::admission(AdmissionError::Invalid, "stop allows at most four nonempty strings totaling at most 4096 UTF-8 bytes")→"code": "invalid_request". Pinned by helios/src/server/runtime/phase_tests.rs:8719-8736 (assert_envelope(..., "invalid_request_error", "invalid_request")). So two adjacent lines of the same validation function family emit differenterror.codestrings for the same class of client mistake. Also affected: sampling (helios/src/model.rs:231,237,251),top_k/seedtype errors (request.rs:710,724), token stops (stops.rs:22), output-limit >uint32 (request.rs:610). Impact: a client branching oncode == "invalid_request_error"stops matching sampling/stop errors;codenow encodes internal layering, not the wire contract. No in-repo consumer depends on the code value (tests/server/test_protocols.py:620 and tests/server/test_decisions.py:218 assert onlytype; grep of flare-winui for these strings returns nothing), but docs/api.md:248-259 still documents its 400s asinvalid_request_error. Fix: either leaveAdmissionError::Invalidon the untypedHttp(400, …)arm so only #446's four codes change, or type the remaining untyped preparation 400s the same way and update docs/api.md + tests so one client error class has one code.
#3 [high] Verified sound areas: no status/concurrency/header change; no consumers of code
Verified at PR head 2f72e1b (files: helios/src/server/http.rs +86/−23, helios/src/server/runtime/phase_tests.rs +356/−0).
Sound areas (no finding):
- Status codes cannot change. Every admission variant reachable from preparation is 400 (
Contextrequest.rs:352-367/592-630,Featurerequest.rs:1133-1137 + inference.rs:213-215,Grammargrammar.rs:543-582 + grammar/strict.rs:40,Imagerequest.rs:1152-1230,Invalidstops.rs:22-84 / model.rs:229-257 / request.rs:610-616,710,724).Capacity/Unavailableappear nowhere in request.rs, model.rs, or frontend/, sostatus()(server.rs:733-741) yields no 503 on this path. - No concurrency/latency/memory change: spawn_blocking structure, the
permit/ingressguards (http.rs:209-211), semaphore acquisition and theextragroup permit (http.rs:248-263) are untouched; the only moved work is computing the hint-suffixed message, which happens after the join (http.rs:290). No new locks, allocation, or buffering. x-request-idcontract preserved: onlyrejectionadds it (http.rs:40) and onlyrejectionlogs (http.rs:39); prep failures go throughfailure_response(http.rs:26-31), matching docs/core-design.md:1119-1121 and docs/api.md:258.- Anthropic envelope preserved:
Protocol::failureonly overwritescodefor non-Messages (protocol/mod.rs:53-59), so /v1/messages and /v1/messages/count_tokens keep{"type":"error","error":{"type","message"}}with the hook applied. - Untyped bodies byte-identical to before: old code wrapped non-Admission errors as
AdmissionError::Invalidthen flattened viaProtocol::error; newHttp(400, e.to_string())renders through the sameProtocol::error(protocol/mod.rs:33-51). decode_body statuses 400/413/415 untouched (http.rs:73-118), andaxum::body::to_bytes413 (http.rs:181-188) untouched. - No in-repo consumer reads these
codestrings: tests/server/test_protocols.py:620 and tests/server/test_decisions.py:218 assert onlytype;flare-winui/has no match for the typed-code strings. - Tests are real behaviour tests, not mocks: unit test http.rs:739-786 covers the mapping; wire test phase_tests.rs:8438-8792 drives
http::generatefor all five routes, buffered and stream, with hints, and assertsreceiver.try_recv().is_err(). Existing post-admission test phase_tests.rs:5132-5208 is untouched. - Test totals (1,880 helios / 254 flare / 245 flare-cli) are unverifiable here; no CI checks on head, no review. GPU serving and tests/server/test_protocols.py were disclosed as unrun.
#5 [high] Research summary
I reviewed PR #689 (helios/server: preserve typed error codes on HTTP request preparation failures, head 2f72e1b) through the Correctness, Contracts & System-Level Consequences lens. I read the full diff, the whole of helios/src/server/http.rs at the PR head, the error/status/code plumbing (helios/src/error.rs, helios/src/server.rs:733-755, helios/src/server/protocol/mod.rs:33-59), the preparation callees (helios/src/server/request.rs:23-420 and :592-730, :1120-1233; helios/src/server/stops.rs; helios/src/model.rs:229-257; helios/src/grammar.rs:543-582), both test sites, the contracts in docs/api.md and docs/core-design.md, issue #446, and the in-repo consumers of error.code (tests/server, flare-winui). Findings are in scratchpad entries 1-4.
Three findings, none a blocker:
A (Major) — code now encodes internal validation layering, and the change exceeds what #446 asked for. preparation_error (http.rs:124-132) routes every Error::Admission(_) through Protocol::failure, and AdmissionError::Invalid maps to "invalid_request" (server.rs:751). Issue #446 asks only for the four codes context_length_exceeded, unsupported_feature, invalid_grammar, invalid_image. The result is two adjacent client-input 400s with different code: "max_tokens": 0 returns invalid_request_error (request.rs:615-616 produces a &str error → ExecutionError::State, pinned by the PR's own test at phase_tests.rs:8737-8759) while "stop": [5 strings] returns invalid_request (stops.rs:63-72, pinned at phase_tests.rs:8719-8736). Sampling errors, top_k/seed type errors, token stops and >uint32 output limits are affected the same way. No in-repo consumer branches on these codes, so nothing breaks in-tree, but a client branching on invalid_request_error silently stops matching. Fix: keep AdmissionError::Invalid on the untyped arm, or type the remaining untyped preparation 400s too so one client-error class has one code.
B (Minor) — the hardcoded 400 in the catch-all arm blames the client for internal failures. other => PreparationError::Http(StatusCode::BAD_REQUEST, other.to_string()) (http.rs:130) hardcodes the status, while status(&error) (server.rs:733-741) says 500 for Error::Execution(_) and Error::Frontend(Asset|Template|Tokenizer|Input). Tokenizer/asset/template failures reached through prepare_validated_inference (via frontend.encode at request.rs:178 → frontend/mod.rs:703 (not opened)/1016/1022) are reported as HTTP 400. This matches old behaviour, and the hardcoded 400 is also what keeps ordinary validation strings at 400; but it means the description's "HTTP status from status(&error)" is not true of this arm, and the 400/500 boundary is not recoverable from the error type on this path.
C (Minor) — docs/api.md now contradicts the wire. api.md:248-259 still says malformed, unsupported and over-context 400s use invalid_request_error; after the PR those carry the typed codes. docs/core-design.md:1115-1119 already promised typed codes, so this is doc debt rather than a design change, but it should be one sentence in api.md (#638 set the precedent).
Everything else I checked is sound and I found no issues: no HTTP status can change (Capacity/Unavailable never arise during preparation), no concurrency, memory, buffering or latency change (spawn_blocking structure, permit/ingress guards and the group permit are untouched), the x-request-id and failure-log contract is preserved because only rejection adds them, the Anthropic envelope is untouched, untyped bodies are byte-identical to before, and the two added tests are genuine behaviour tests (one drives http::generate across all five routes, buffered and streamed, asserting zero model-queue admissions). The reported test totals remain unverifiable: no CI checks on the head commit and the GPU/Python suites were disclosed as unrun.
#6 [high] Claim-accuracy audit of the PR description vs the diff
Audited every material claim in the PR body against the diff at 2f72e1b.
Holds:
- Typed codes on all five routes: http.rs:124-132 + server.rs:743-755, asserted by phase_tests.rs:8561-8717.
- Open
error.param: null, Messages without code/param: protocol/mod.rs:44-51 (only non-Messages getparam/code) and :53-59 (only non-Messages geterror_code); asserted phase_tests.rs:8526-8537. - Untyped 400/413/415 keep status and
invalid_request_error/request_too_large: decode_body (http.rs:73-118) untouched;axum::body::to_bytes413 (http.rs:181-188) untouched; asserted phase_tests.rs:8761-8791 twice (400 and 400 on reasons). - No
x-request-idon preparation failures: onlyrejectioninserts it (http.rs:40) and logs (http.rs:39); preparation goes throughfailure_response(http.rs:26-31). Asserted phase_tests.rs:8509-8512. - Zero model-queue admissions: asserted with
receiver.try_recv().is_err()after every case.
No-op claim ("context_hint / capacity_hint preserved in error.message"): the pre-PR code already preserved it. The removed map_err passed typed admission errors through unchanged —
match e { Error::Admission(_) => e, _ => e.admission_context(AdmissionError::Invalid) } (PR diff, http.rs hunk at the old line 258-267) — and rejection_details (http.rs:60-72) matches Error::Admission(AdmissionError::Context(_)) to append state.context_hint. So hints worked before and after; only code changes. The description presents this as a preserved property of the fix rather than an unchanged one.
Vacuous / imprecise claim ("HTTP status from status(&error)"): true but no status can change, because every admission variant reachable during preparation is 400 (server.rs:733-741; Capacity/Unavailable appear nowhere in request.rs, model.rs, frontend/, or grammar.rs). And it is untrue of the catch-all arm, which hardcodes StatusCode::BAD_REQUEST (http.rs:130) even where status(&error) would say 500 — see scratchpad entry 2.
Incomplete claim ("Wraps Frontend(FrontendError::ImageDecode(_)) as AdmissionError::Image, matching request::prepare"): accurate only for the ImageDecode case. request::prepare (request.rs:30-36) types every non-Admission error as AdmissionError::Invalid; preparation_error flattens all non-Admission, non-ImageDecode errors to HTTP 400 instead. The asymmetry is deliberate (it is what keeps untyped bodies byte-identical) but the description does not say the two paths diverge for Asset/Template/Tokenizer/Input.
Undeclared client-visible change: explicit AdmissionError::Invalid now emits "code": "invalid_request" instead of "invalid_request_error" (server.rs:751, test phase_tests.rs:8734). Issue #446 lists only the four codes; this fifth, broader class covers ordinary 400s such as bad stop (stops.rs:63-72) and bad sampling (model.rs:229-257).
Unverifiable: helios 1,880 passed / 84 ignored, flare 254, flare-cli 245 — no CI checks on head 2f72e1b (single commit, no review, no labels), so these are local-only counts. Live GPU serving and tests/server/test_protocols.py were disclosed as unrun, which is honest; the Python assertions in reach check only error["type"] (test_protocols.py:620, test_decisions.py:218) and would very likely still pass.
#7 [high] Report outline: verdict, findings A/B/C, verified-sound list
Final report structure (details in entries 1-5; do not repeat them in full).
Scope statement: read the full diff, all of helios/src/server/http.rs at head, the error/status/code plumbing, every preparation callee, both test sites, docs/api.md and docs/core-design.md, issue #446, and the in-repo consumers of error.code. No competing PR modifies the same rendering helpers (decisions endpoints already rendered Protocol::failure, protocol/decisions/mod.rs:215-226 and :282-292 — #689 generalises that pattern and creates no new one).
Verdict: the change is small, well-tested and correct in its main path; no Blocker. Three findings.
-
Major — entry 1.
codenow depends on internal validation layering; two adjacent client-input 400s get different codes (max_tokens: 0→ invalid_request_error vsstop: [5]→ invalid_request), and theinvalid_requestclass exceeds what #446 asked for. Fix: keepAdmissionError::Invaliduntyped, or type the rest and update docs. -
Minor — entry 2. Hardcoded 400 at http.rs:130 reports 400 where
status()would say 500 forError::Execution(_)/Frontend(Asset|Template|Tokenizer|Input). Pre-existing behaviour, but it makesstatus(&error)undrivable from the error type on this path and contradicts the description's framing. -
Minor — entry 4. docs/api.md:248-259 still documents all these 400s as
invalid_request_error; the typed strings appear nowhere under docs/. One sentence needed; docs/core-design.md:1115-1119 already promised typed codes, so this is doc debt, not a design change.
Verified sound (state plainly, do not invent issues): no HTTP status can change; no concurrency, lock, memory, buffering or latency change (spawn_blocking structure, permit/ingress guards and the group permit untouched; the hint message is computed after the join); x-request-id and failure-log contract preserved; Anthropic envelope untouched; untyped bodies byte-identical to before; tests are real behaviour tests covering all five routes buffered and streamed. Charter fit is good: smallest footprint in one shared file, no new config/flag/dependency, no per-model branch, description has why/what/result/evidence/limitations.
Also say: preparation failures still are not logged to failure_log and not counted in flare_requests_failed_total (metrics.rs:1091-1095) — unchanged from before, so not a regression, but worth reading with the same author's #692; and test totals are not independently reproducible (no CI on head, GPU/Python suites unrun).
#2 [medium] Finding B (Minor): hardcoded 400 misreports internal Frontend/Execution preparation failures
helios/src/server/http.rs:130 other => PreparationError::Http(StatusCode::BAD_REQUEST, other.to_string()), hardcodes 400 for everything that is not Admission or ImageDecode. helios/src/server.rs:733-741 is the authoritative mapping:
fn status(failure: &Error) -> StatusCode {
match failure {
Error::Admission(AdmissionError::Capacity(_) | AdmissionError::Unavailable(_)) => {
StatusCode::SERVICE_UNAVAILABLE
}
Error::Admission(_) => StatusCode::BAD_REQUEST,
_ => StatusCode::INTERNAL_SERVER_ERROR,
}
}
so Error::Execution(_) and Error::Frontend(Asset|Template|Tokenizer|Input) are 500 per status() but 400 per preparation_error.
Reachable internal failures routed through request::prepare_validated_inference (helios/src/server/http.rs:270-280) that are blamed on the client:
frontend.encode(...)at helios/src/server/request.rs:178 → helios/src/frontend/mod.rs:703,1016,1022Error::frontend(FrontendError::Tokenizer(...))(tokenizer runtime failure).FrontendError::Asset(frontend/mod.rs:44,52,77,84) andTemplate(frontend/mod.rs:1046,1053) if asset/template evaluation fails at request time. This is preserved pre-existing behaviour, not introduced by the PR, and it is the direct reasonstatus(&error)cannot simply be used here:Error::from(&str)(error.rs:174-183) makes ordinary validation stringsExecutionError::State, i.e. 500 perstatus(). The PR description's "Thread-typed" framing impliesstatus(&error)drives the status ("HTTP status fromstatus(&error)"), which is not true for this arm. Fix: at minimum state the constraint in a comment next to the arm and, if wanted, split the execution variant out (Error::Execution(_) => Http(status(&error), …)) once untyped validation strings stop being modelled asExecutionError::State; otherwise the 400/500 boundary in Helios remains untestable from the error type on the preparation path.
#4 [medium] Finding C (Minor): docs/api.md contract now wrong for typed preparation 400s
docs/api.md:248-259 (unchanged by the PR) still assigns one code to all these 400s:
Chat Completions, Completions, and Responses errors are
`{"error": {"type", "message", "param": null, "code"}}`; Messages errors are
`{"type": "error", "error": {"type", "message"}}`. Malformed, unsupported, and
over-context requests return HTTP 400 (`invalid_request_error`); a missing or
After this PR an over-context or unsupported-feature request on the same routes returns "code": "context_length_exceeded" / "unsupported_feature" while type stays invalid_request_error (helios/src/server/protocol/mod.rs:33-51 + helios/src/server.rs:743-755). So the document's parenthetical is now wrong for exactly the cases the PR changes, in the table a client author reads. The typed strings appear nowhere under docs/ (grep for context_length_exceeded|unsupported_feature|invalid_grammar|invalid_image over docs/ returns only api.md:232,251 for invalid_request_error).
The internal design doc already promises the new behaviour, so this is a doc-debt, not a design change: docs/core-design.md:1115-1119 "Failures observed before response headers use the corresponding HTTP error status … Chat and completion errors include type, message, param, and a typed code". Precedent for updating api.md with a wire change: #638.
Fix: add one sentence to docs/api.md naming the typed 400 codes (context_length_exceeded, unsupported_feature, invalid_grammar, invalid_image, invalid_request) and stating that type remains invalid_request_error. Severity Minor (docs only), but it is the contract a code-branching client will read.