Case file — PR #689: helios/server: preserve typed error codes on HTTP request preparation failures
https://github.com/NVIDIA/hyperflare-inference/pull/689 · author jcartu · opened 2026-12-02 · head 2f72e1b (single commit 2f72e1bb, branch fix/preparation-typed-error-codes) · base main · +442 / −23 in 2 files · fixes #446 · Discord: jcartu
Key findings
- The change is real and small in effect: every typed preparation failure reachable today is an
AdmissionErrorwhosestatus()is 400 (server.rs:733-741), so no HTTP status code changes; onlyerror.code(and the Anthropic envelope stays untouched) changes. The description's wording "HTTP status fromstatus(&error)" is true but vacuous for preparation (Capacity/Unavailable cannot arise there). - A client-visible code change the description buries: explicit
AdmissionError::Invalidnow renders"code": "invalid_request"instead of"invalid_request_error"(http.rs:124-132, test phase_tests.rs:8719-8736 with 5stopsequences). Issue #446 lists onlycontext_length_exceeded,unsupported_feature,invalid_grammar,invalid_image; this is a fifth, broader class of 400s that changes wire output. - An undeclared asymmetry:
preparation_errorspecial-cases onlyFrontendError::ImageDecode; otherFrontendErrorvariants (Asset,Template,Tokenizer,Input; error.rs:131-143) that surface during preparation still flatten toinvalid_request_error, whereasrequest::prepare(request.rs:30-36) types everything non-Admission asAdmissionError::Invalid. The description only claims the wrap "matchesrequest::prepare" for images. - No CI, no review, no labels, same-day age: the head commit has no checks, and the reported test totals (helios 1,880 passed / 84 ignored; flare 254; flare-cli 245) are local runs only. The same author's same-day PRs report slightly different helios totals (#692: 1,884 passed; #691: 1,821 lib + 62 integration), consistent with per-branch local runs.
- The documentation already promised this behaviour, so #689 is a bug fix against an existing contract rather than a design change: docs/core-design.md:1115-1119 says pre-header failures use the corresponding HTTP status and that "Chat and completion errors include
type,message,param, and a typedcode". No docs are changed, and docs/api.md:250-251 still describes 400s only asinvalid_request_error, so acode-aware client reading api.md learns nothing about the new strings. - Operators get no new log line: preparation rejections still do not call
log_failure(kept inrejection, http.rs:32-41) and still do not incrementflare_requests_failed_total; that matches the old behaviour but is worth reading together with the same author's #692, which reworks failure accounting in the same file. - No competing or overlapping PR: nothing else changes the error-rendering code; the decision-serving path (
/v1/decisions,/v1/systemone) already renderedProtocol::failurefrom insidespawn_blocking(protocol/decisions/mod.rs:216-226, 282-292), so #689 closes the last straggler.
1. The change
Files (per pr_files/diff): helios/src/server/http.rs (+86/−23), helios/src/server/runtime/phase_tests.rs (+356/−0). No docs, no config, no public API.
What it does, verified at the PR head:
failure_response(&HttpState, Protocol, Error) -> Response(http.rs:26-31) — buildsprotocol.failure(&failure), then overwritesbody["error"]["message"]with therejection_detailsmessage and takes the status fromrejection_details(i.e.status(&failure), withcontext_hint/capacity_hintappended).rejectionnow delegates (http.rs:32-41):log_failure(only whenstate.log_to_stderr) pluswith_request_id(failure_response(...), id).x-request-idand stderr logging therefore stay post-submission only.PreparationError/preparation_error(http.rs:119-132):Error::Admission(_)→Failure(error)unchanged;Error::Frontend(FrontendError::ImageDecode(_))→Failure(error.admission_context(AdmissionError::Image)), mirroringrequest::prepare(request.rs:30-36) anddescribe_images(request.rs:1141, 1194-1230);- everything else →
Http(StatusCode::BAD_REQUEST, error.to_string()).
generatedispatch (http.rs:209-291):decode_bodymaps its(StatusCode, String)toHttp(keeping 400/415/413);protocol::decode, the per-toolGrammarCompiler::compile_textloop,Request::generation_count,request::compile_strict_validators, and eachrequest::prepare_validated_inferencecall usemap_err(preparation_error); the oversized-generation-group 400 and theTOO_MANY_REQUESTSnative-admission failure stayHttp. Thematchon the join result addsFailure(failure) => failure_response(&state, protocol, failure); join errors are still 500.- Untyped preparation errors keep their exact wire body. Before, non-
Admissionerrors were wrapped intoAdmissionError::Invalidinside themap_errsolely to obtain a 400 fromrejection_details, then flattened byhttp::error; now they takeHttp(400, to_string())and still render throughProtocol::error→type = code = "invalid_request_error"(protocol/mod.rs:33-51). - Hints already worked and still work. The old
map_errpreserved typedContexterrors, socontext_hintwas applied then too; the description's "hints preserved" is a no-op claim.capacity_hintcan never apply on the preparation path. - Tests: unit test
preparation_error_preserves_typed_admission_errors_and_keeps_untyped_bad_requests(http.rs:739-786) asserts codes for Context/Feature/Grammar/Image/ImageDecode/Invalid and HTTP 400 for an untyped string error; wire testhttp_preparation_failures_preserve_typed_error_codes_and_protocol_envelopes(phase_tests.rs:8438-8792) driveshttp::generatewith aFixturemodel andmax_sequence_tokens = 8, covering/v1/chat/completions,/v1/completions,/v1/responses,/v1/messages,/v1/messages/count_tokens, buffered andstream: true, assertingx-request-idabsent (phase_tests.rs:8509-8512),param: nullpresent, Messages envelope withoutcode/param(8526-8537), andreceiver.try_recv().is_err()(zero model-queue admissions) throughout.
Typed-code plumbing this relies on (unchanged by the PR): status (server.rs:733-741) and error_code (server.rs:743-755) — Context→context_length_exceeded, Feature→unsupported_feature, Grammar→invalid_grammar, Image→invalid_image, Invalid→invalid_request, Capacity→capacity_exhausted, Unavailable→server_unavailable; Protocol::failure overwriting error.code (protocol/mod.rs:53-58).
2. The why
Issue #446 (open; labels area:api, bug; shieldstar, opened 2026-11-21; updated 2026-11-21) is the sole driver and is linked as "fixes". Its report is a pure-renderer reproduction at upstream 25b49519 with printed bodies showing Protocol::failure yielding typed codes while http::error/Protocol::error yields code = type = "invalid_request_error", plus source pointers (protocol/mod.rs:33-46, :53-58, server.rs:655 error_code, http.rs:259-267, http.rs:275, http.rs:12-17). Its "Suggested fix" is exactly what #689 implements: return protocol.failure(&error) with status(&error) instead of rejection_details(...) + error(...).
Independent confirmation: yatesdr (49 commits in helios/src over 180 days) commented 2026-11-21 18:38 "Confirmed by reading at main 21a40f05 … Only Protocol::failure uses the typed codes … No test covers the preparation path." The issue has this one comment and no reactions recorded; it is ~11 days old and untouched since, i.e. the problem is newly reported, not long-running community demand.
3. Related work
- No competing or overlapping PR.
related_items(689)lists only #446; no other open/closed PR modifies the error-rendering helpers. - Same-file neighbours, all disjoint in intent:
- #692 (open, jcartu, opened 2026-12-02): counts output-stream failures under
requests_failed_total; toucheshttp.rs+runtime.rs. Complementary to #689's "preparation failures are not counted as failures" gap. - #691 (open, jcartu, 2026-12-02): reports reused prompt tokens in
continuous_usage_statschunks; toucheshttp.rs,encode.rs(not opened),runtime.rs. - #548, #560 (open): per-request histograms / vLLM-parity metrics; touch
http.rsandphase_tests.rs. - Both #691 and #692 edit the same
http::generatepreamble/event loop, so textual conflicts with #689 are plausible; #689's own hunks are the top-of-file helpers and the preparation closure.
- #692 (open, jcartu, opened 2026-12-02): counts output-stream failures under
- Direct lineage / dependencies:
- #418 (merged, jcartu, "Add strict function-tool schemas for DSML, Qwen, GLM and TML parsers") introduced
compile_strict_validators(request.rs:88-113), which #689 now routes throughpreparation_error; the strict-schema failure originates asAdmissionError::Grammar(grammar/strict.rs:40 (not opened)). - #638 (merged 2026-12-01, "Echo Responses tools and text.format…") added the neighbouring test
get_responses_returns_bad_request…at http.rs:720-737 that #689's unit test sits next to, and it did edit docs for its wire change — a precedent a reviewer may apply here. - #176 (merged, yatesdr) introduced the
x-request-id+ failure-log contract that #689 deliberately preserves; #317 and #333 are earlier ingress/x-request-id work. - #615, #670, #575 touch the same request-preparation code but not the error rendering.
- #418 (merged, jcartu, "Add strict function-tool schemas for DSML, Qwen, GLM and TML parsers") introduced
- Untouched sibling path: the decisions endpoints already render typed failures inside
spawn_blocking(protocol/decisions/mod.rs:216-226, 282-292), which is the pattern #689 generalises; nobody has proposed changing it. - Existing tests adjacent to this behaviour:
http_admission_rejections_use_json_or_terminal_stream_errors(phase_tests.rs:5132-5210, post-admission Capacity/Unavailable/Context withx-request-id),stream_errors_preserve_typed_codes_and_protocol_envelopes(protocol/tests.rs:1485-1545).
4. Recent activity in the touched areas
helios/src is busy and owned by a small group: last 60 days of commits include #681, #661, #665, #660 (PCCessna, scheduler), #670, #667 (Luke Alonso), #663 (yatesdr), #666 (Jason Cook). Over 180 days: Luke Alonso 237 commits, Martin Vit 52, yatesdr 49. Recent http.rs/server.rs work: flare-autobot (#638), jedi95 (#317), yatesdr (#176, #167, #333), Luke Alonso's HTTP-ingress hardening (2026-11-19). No commit on main since #689 branched (c513e46) touches its changed files, so no rebase or semantic conflict with main yet.
5. People
- jcartu / Joshua Cartu — GitHub association CONTRIBUTOR; not one of the charter's named priority contributors. 180-day record: 3 merged, 3 closed, 10 open PRs. Merged helios/src work:
0b09434d(#418 strict tool schemas),85de9eae(FP32 parameter binding),425ab2d4(#416 prefix-cache recency). Substantial batch submission on 2026-12-02: #686, #687, #688, #689, #690, #691, #692, #693 all opened that day, three of them touchinghttp.rs. - Review history: #621 (same author) received Autobot reviews (Changes Requested → Ready To Merge); jcartu engages with Autobot review threads, and case files were produced for their PRs.
- Area owners to consult: Luke Alonso, yatesdr, Martin Vit. yatesdr has effectively pre-approved the problem by confirming #446.
- On #689 so far: no human review, no comments, no Autobot case-file comment yet (
pr_commentsreturns "No comments"), and no labels.
6. Community
Nothing to gauge: zero comments, zero reviews, zero reactions, no labels, opened and last updated the same day. There is no expressed interest beyond the linked issue #446 and its single confirming comment by yatesdr.
7. Project fit
- Direct documentation support: 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 typedcode". #689 makes the preparation path obey an already-documented contract. docs/core-design.md:1119-1121 restrictsx-request-idto "After frontend preparation", which is exactly what #689 preserves. helios/README.md:92-99 documents the status mapping and thecontext_hint/capacity_hintsuffixes, still accurate. - Documentation gap left open: docs/api.md:248-259 names only
invalid_request_errorfor malformed/unsupported/over-context 400s; the stringscontext_length_exceeded,unsupported_feature,invalid_grammar,invalid_image,invalid_requestappear nowhere underdocs/. After #689typestaysinvalid_request_error, so api.md is not literally contradicted, but thecodestory is incomplete. Sibling PR #638 did add api.md text for its change, so a reviewer may ask for parity. - Charter alignment: "Bring real evidence … Bug fixes need to address the root cause" (root cause = rendering through the untyped path, fixed at the shared HTTP layer); "Solve the right problem in the right place … smallest footprint in shared code" (private helpers in one file, no per-model branches); "Support the documented Chat Completions, Completions, Responses, and Messages APIs". No new config, default, flag or dependency, so none of the "no magic defaults / no extra switches" rules are brushed. The PR description has why/what changed/claimed result/evidence/limitations as the charter asks.
- Potential tension a reviewer could raise: the
AdmissionError::Invalid→invalid_requestchange affects the largest class of 400s (badstop, bad sampling params, etc.) and is not requested by #446; it makescodediverge fromtypefor common client mistakes, which is arguably scope creep even though it is internally consistent witherror_code.
8. Claims and evidence
| Claim | Evidence |
|---|---|
Typed preparation failures carry typed code on all five routes |
Verified in code (http.rs:124-132, 209-291) and by the wire test (phase_tests.rs:8561-8599 context, 8601-8638 feature, 8640-8695 grammar, 8697-8717 image). Backed. |
Messages envelope unchanged (no code/param) with context_hint kept |
Verified: Protocol::failure only overwrites code for non-Messages (protocol/mod.rs:53-58); asserted phase_tests.rs:8526-8537, 8585-8597. Backed. |
param: null explicit |
protocol/mod.rs:48 sets it for non-Messages; asserted phase_tests.rs:8532-8536. Backed. |
Buntyp/HTTP errors keep 400/413/415 and invalid_request_error/request_too_large |
Verified: decode_body statuses untouched (http.rs:73-118); test phase_tests.rs:8761-8791 exercises {, {}, unknown Content-Encoding, 4,200-byte body. Backed. |
status(&error) used |
True, but every reachable preparation admission variant is 400 (server.rs:733-741); no status changes anywhere. |
invalid_image on both invalid base64 and corrupt PNG |
Test uses an image-enabled HttpState (phase_tests.rs:8712) with AAAA PNG stub; backed by construction of describe_images (request.rs:1141, 1194-1230). |
No x-request-id on preparation failures |
Verified by construction (http.rs:26-41) and asserted (phase_tests.rs:8509-8512); consistent with docs/api.md:258 and docs/core-design.md:1119-1121. |
| Zero model-queue admissions | Asserted via receiver.try_recv().is_err() after every case. |
| Test totals: helios 1,880 passed / 84 ignored; flare 254; flare-cli 245 | Unverifiable here; no CI on head 2f72e1b ("no checks"), so nothing independently reproduces them. .github/workflows/native-serving.yml:63 (not opened),68 runs exactly cargo test --locked --release --manifest-path helios/Cargo.toml (not opened) --features runtime-core,server, so CI would cover the new tests once it runs. Sibling PRs from the same day report 1,884 (#692) and 1,821+62 (#691) — branch-local counts. |
Limitations disclosed (no GPU serving, no tests/server/test_protocols.py) |
Honest; the added tests are CPU/axum-level. The Python assertions in reach (test_protocols.py:616-624, test_decisions.py:203-218) check only error["type"], so they would very likely still pass, but they were not run. |
Not claimed but true (may matter to a reviewer): preparation failures are still not written to failure_log and not counted in flare_requests_failed_total; both match the old behaviour, so this is not a regression.
9. Reach
- Clients: OpenAI-SDK consumers of
/v1/chat/completions,/v1/completions,/v1/responsesseeerror.codechange frominvalid_request_errortocontext_length_exceeded/unsupported_feature/invalid_grammar/invalid_image/invalid_request;error.typestaysinvalid_request_error,paramstaysnull. Anthropic/v1/messagesand/v1/messages/count_tokensbodies are byte-identical in shape (nocode, noparam). Any client branching oncode == "invalid_request_error"will behave differently for these 400s. No in-repo test or client does so: tests/server/test_protocols.py:620 and test_decisions.py:218 assert onlytype; test_protocols.py:85 assertscode == "model_not_found", unaffected. - Status codes / retry logic: unchanged (all 400), so no retry behaviour change.
- Operators: no header/log/metric change; no new configuration, default or dependency; nothing to deploy.
- Rust surface:
PreparationError,preparation_error,failure_responseare private tohelios/src/server/http.rs; no public API change. - Documentation: no doc edits, and none strictly required (core-design already promises typed codes); api.md could be extended to list the typed 400 codes, as #638 did for its contract change.
10. Process
Open, marked "ready for review", opened and last updated 2026-12-02 (same-day, fresh at time of analysis). 0 reviews, 0 comments, 0 labels, 0 CI checks on head 2f72e1b, single commit on fix/preparation-typed-error-codes. No maintainer has engaged; the only prior signal is yatesdr's confirmation on #446.
Open questions / not found
- Whether maintainers want
AdmissionError::Invalid→invalid_request(beyond #446's four codes) or want it left atinvalid_request_errorto keep the diff minimal. - Whether
FrontendError::Asset/Template/Tokenizer/Input(error.rs:131-143) surfacing during preparation should also be typed (request::prepareat request.rs:35 types themInvalid), and whetherprepare's typing orpreparation_error's is the intended contract. - Whether preparation rejections should be logged (
failure_log) and counted inflare_requests_failed_total, which the same author's #692 reworks. - Whether docs/api.md should list the typed 400 codes, mirroring #638.
- No CI evidence, no review evidence, and no reaction/community engagement exists to weigh; test totals cannot be reproduced from this environment.