Recommendation: Changes Requested
PR #689 cleanly fixes the core #446 defect by carrying typed Error values across http::generate's spawn_blocking boundary and rendering them through the shared Protocol::failure + rejection_details path without altering x-request-id, failure logging, HTTP status codes, or concurrency/permit lifetimes. Before merging, resolve the wire-level error.code split introduced by routing AdmissionError::Invalid to "invalid_request" while adjacent validation checks on the exact same fields still emit "invalid_request_error", and trim the unreachable FrontendError::ImageDecode branch and duplicated HttpState struct literal in the new test.
Merge Risk
Level: Low
- Changes are strictly confined to
helios/src/server/http.rs(+86/−23) andhelios/src/server/runtime/phase_tests.rs(+356/−0); no model-core, Protobuf, scheduler, prefix-cache, or CUDA-graph code is touched, and no HTTP status codes change (all reachable preparationAdmissionErrorvariants map to HTTP 400 athelios/src/server.rs:733-741). - No concurrency, lock, permit-lifetime, or hot-path overhead regression:
frontend_slots(_permit),ingress_slots(_ingress), andextragroup-permit lifetimes insidespawn_blocking(helios/src/server/http.rs:209-284) are unchanged, andfailure_responseruns post-join on the error path only. - On OpenAI-shaped routes (
/v1/chat/completions,/v1/completions,/v1/responses),error.codechanges from"invalid_request_error"to typed codes (context_length_exceeded,unsupported_feature,invalid_grammar,invalid_image, and currentlyinvalid_request), whileerror.typestays"invalid_request_error",error.paramstaysnull, and Anthropic/v1/messagesenvelopes are unchanged.
Walkthrough
- Shared failure renderer (
helios/src/server/http.rs:26-41): extractsfailure_response(&HttpState, Protocol, Error) -> Responseusingprotocol.failure(&failure)andrejection_details(state, failure)for hint-suffixed messages;rejectiondelegates tofailure_responsewhile keepinglog_failureandwith_request_idpost-submission only (matchingdocs/core-design.md:1119-1121anddocs/api.md:258-259). - Preparation error classifier (
helios/src/server/http.rs:119-132): introduces privatePreparationError::{Http, Failure}andpreparation_error(Error)soError::Admission(_)(andFrontendError::ImageDecode(_)) preserve typed failures while non-admission errors map toPreparationError::Http(StatusCode::BAD_REQUEST, ...). - Generation preparation dispatch (
helios/src/server/http.rs:209-293): routesprotocol::decode,GrammarCompiler::compile_text,Request::generation_count,request::compile_strict_validators, andrequest::prepare_validated_inferencethroughpreparation_error, dispatchingPreparationError::Failuretofailure_responseandPreparationError::Httptohttp::error(keepingdecode_body400/413/415, oversized-group 400, and admission-full 429 onhttp::error). - Tests (
helios/src/server/http.rs:739-786,helios/src/server/runtime/phase_tests.rs:8438-8792): adds a unit test forpreparation_errorand an end-to-endhttp::generatetest covering/v1/chat/completions,/v1/completions,/v1/responses,/v1/messages, and/v1/messages/count_tokens(buffered andstream: true), asserting typederror.code,context_hint, explicitparam: null, Anthropic envelope shape, absentx-request-id, and zero model-queue admissions (receiver.try_recv().is_err()).
Pre-merge Checks
- [PASS] Security / malicious screen: No unsafe code, external I/O, or prompt-injection/instruction-directing content found in the PR description, comments, or diff.
- [PASS] Charter & value fit: Directly addresses maintainer-confirmed bug #446 in Helios's shared HTTP layer with no per-model branches, flags, defaults, or dependencies, and includes the four required PR description sections plus Discord contact.
- [PASS] Related / duplicate / conflict check: No competing or superseding PR; cleanly based after #638 (
cd1daa3e) with no conflicts againstmain(open same-file PRs #691, #692, #548, #560 are disjoint in intent). - [WARN] Tests & verification evidence: Added Rust CPU tests are isolated (per-test
Fixture::with_templatePID/serial temp dirs cleaned up immediately, no global state) and exercise realhttp::generate; scheduler/TLA+/Kani gates do not apply. However, no CI check results are visible on head2f72e1b(only local test counts reported), and live GPU /tests/server/test_protocols.py(not opened) runs were not executed (disclosed) — confirm greenNative servingCI before merge.
Blockers
None.
Should Fix
- Unintended
error.codesplit across ordinary 400 validation errors (helios/src/server/http.rs:124-132,helios/src/server.rs:751,helios/src/server/runtime/phase_tests.rs:8719-8759):- Routing all
Error::Admission(_)variants throughPreparationError::FailurecausesAdmissionError::Invalidto emit"code": "invalid_request"(helios/src/server.rs:751), while sibling validation errors raised viaError::from(&str)(mapped toExecutionError::Stateathelios/src/error.rs:174-183) hit the catch-all arm and emit"code": "invalid_request_error". - This splits adjacent checks on the exact same request fields across two different wire
error.codevalues based solely on internal Rust error construction:max_tokens > u32::MAX(helios/src/server/request.rs:609-614,AdmissionError::Invalid) emits"invalid_request", whilemax_tokens == 0ormax_tokens > i32::MAX(helios/src/server/request.rs:615-617,&str) emits"invalid_request_error".- Bad
temperature/top_p/seed(helios/src/server/request.rs:709-727,helios/src/model.rs:229-256) emit"invalid_request", while non-integertop_k(helios/src/server/request.rs:684,&str) emits"invalid_request_error". stopcombined with structured output (helios/src/server/stops.rs:79-84) emits"invalid_request", whilestop_token_idscombined with structured output (helios/src/server/request.rs:340-342) emits"invalid_request_error".
- Issue #446 and its maintainer confirmation specifically target the four typed preparation codes (
context_length_exceeded,unsupported_feature,invalid_grammar,invalid_image), not splitting general 400 validation errors, andphase_tests.rs:8719-8759currently pins both sides of that accidental split. - Fix (choose one):
- Preferred (minimal, matches #446 scope): Keep
Error::Admission(AdmissionError::Invalid(_))on thePreparationError::Http(StatusCode::BAD_REQUEST, ...)arm inpreparation_error(helios/src/server/http.rs:124-132), so general invalid-request 400s stay uniformly"invalid_request_error"and only specific typed admission errors (Context,Feature,Grammar,Image, plusCapacity/Unavailable) emit distinct codes; updatehttp.rs:762-765andphase_tests.rs:8719-8736accordingly. - Alternative (if
"invalid_request"is desired for preparation 400s): Convert the remainingprepare_validated_inferenceclient-input&strerrors (at minimum the siblingoutput_limit,top_k, and structured-output stop checks) toAdmissionError::Invalidso one error class does not emit two codes.
- Preferred (minimal, matches #446 scope): Keep
- Routing all
Subtract / Simplify
- Delete the unreachable
FrontendError::ImageDecodearm inpreparation_error(helios/src/server/http.rs:127-129,758-761):FrontendError::ImageDecodeis only constructed insideImageProcessordecoding (helios/src/frontend/images/mod.rsandorientation.rs(not opened)). Onhttp::generate's preparation path, the only image-decoding caller isdescribe_images(helios/src/server/request.rs:1120-1233), which already wrapscheck_batch,decode_encoded,describe_image,geometry, andcheck_budgetwith.map_err(|error| error.admission_context(AdmissionError::Image))(request.rs:1141, 1194, 1196, 1208, 1230), andcrate::model::prepare_image_inputs(helios/src/model/prompt.rs:37-141) never decodes image bytes.- Remove the dead
Error::Frontend(crate::FrontendError::ImageDecode(_))match arm athelios/src/server/http.rs:127-129and its synthetic unit-test row athelios/src/server/http.rs:758-761.
- Replace the 21-field hand-rebuilt
HttpStateliteral inphase_tests.rs:8452-8480withArc::get_mutonhttp_state_for:make_statebuildsbase = http_state_for(fixture, sender, None, &[])and then copies all 21 fields ofHttpStatesolely to overrideimages,max_body_bytes, andcontext_hint, duplicatinghttp_state_for(phase_tests.rs:4273-4295) and inviting merge conflicts with any PR adding anHttpStatefield.- Follow the existing pattern at
helios/src/server/runtime/phase_tests.rs:5086-5087: mutatelet mut state = http_state_for(fixture, sender, None, &[]);vialet s = Arc::get_mut(&mut state).unwrap();to set onlymax_body_bytes,context_hint, andimages.
Nits
- Document typed 400
error.codevalues indocs/api.md:248-259:docs/api.md:250-251currently mentions only theerror.typecategory (invalid_request_error) for HTTP 400s and none of the typedcodestrings appear anywhere underdocs/. Adding one short sentence noting the typederror.codevalues returned on Chat Completions, Completions, and Responses (context_length_exceeded,unsupported_feature,invalid_grammar,invalid_image, andinvalid_requestif retained) would aligndocs/api.mdwithdocs/core-design.md:1117-1118.
Dropped on verification
- Upstream claim that
seed(request.rs:724),sampling_number(request.rs:710), andTokenStops::new(stops.rs:22) remain untyped: Dropped those inaccurate citations — verified at2f72e1bthat all three already constructError::admission(AdmissionError::Invalid, ...)and emit"invalid_request". Replaced with the actual verified untyped siblings (request.rs:615-617max_tokens == 0 || > i32::MAX,request.rs:684top_k, andrequest.rs:340-342stop_token_ids+ structured output). - Upstream finding that the catch-all arm (
http.rs:130) hardcodes HTTP 400 wherestatus(&error)says 500 and contradicts the PR description: Dropped — this is pre-existing behavior (changing it tostatus(&error)would turn every&str-based validation 400 into a 500 becauseFrom<&str>producesExecutionError::Stateathelios/src/error.rs:174-183), and the PR description accurately scopesstatus(&error)to typed preparation failures while explicitly stating untyped errors map toPreparationError::Http(StatusCode::BAD_REQUEST, message). - Upstream claim of an undeclared asymmetry with
request::prepareforFrontendError::{Asset,Template,Tokenizer,Input}: Dropped as a separate defect —request::prepare(request.rs:23-37) is an in-process helper unused byhttp::generate, keeping non-admission HTTP preparation errors oninvalid_request_errorpreserves pre-PR behavior, and deleting the unreachableImageDecodearm inpreparation_errorremoves the partial copy cleanly. - Upstream suggestion to collapse three test loops in
phase_tests.rs:8603-8717for "~100 lines" saved: Dropped — the three loop bodies are 6 lines each (8632-8638,8689-8695,8711-8717), saving only ~14 lines while merging three readable per-code sections; the "~100 lines" estimate was inflated. - Upstream suggestion to add
impl From<(StatusCode, String)> for PreparationErrorfordecode_body(http.rs:212-213): Dropped — net positive LOC for a single call site.