Final review report · NVIDIA/hyperflare-inference #689

Raw Markdown for agents: https://autobot.eidonix.com/p/435f4005-90bd-4e57-afb4-0e4a13e2a6df.md

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

Walkthrough

Pre-merge Checks

Blockers

None.

Should Fix

  1. Unintended error.code split 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 through PreparationError::Failure causes AdmissionError::Invalid to emit "code": "invalid_request" (helios/src/server.rs:751), while sibling validation errors raised via Error::from(&str) (mapped to ExecutionError::State at helios/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.code values based solely on internal Rust error construction:
      • max_tokens > u32::MAX (helios/src/server/request.rs:609-614, AdmissionError::Invalid) emits "invalid_request", while max_tokens == 0 or max_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-integer top_k (helios/src/server/request.rs:684, &str) emits "invalid_request_error".
      • stop combined with structured output (helios/src/server/stops.rs:79-84) emits "invalid_request", while stop_token_ids combined 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, and phase_tests.rs:8719-8759 currently pins both sides of that accidental split.
    • Fix (choose one):
      • Preferred (minimal, matches #446 scope): Keep Error::Admission(AdmissionError::Invalid(_)) on the PreparationError::Http(StatusCode::BAD_REQUEST, ...) arm in preparation_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, plus Capacity/Unavailable) emit distinct codes; update http.rs:762-765 and phase_tests.rs:8719-8736 accordingly.
      • Alternative (if "invalid_request" is desired for preparation 400s): Convert the remaining prepare_validated_inference client-input &str errors (at minimum the sibling output_limit, top_k, and structured-output stop checks) to AdmissionError::Invalid so one error class does not emit two codes.

Subtract / Simplify

  1. Delete the unreachable FrontendError::ImageDecode arm in preparation_error (helios/src/server/http.rs:127-129, 758-761):
    • FrontendError::ImageDecode is only constructed inside ImageProcessor decoding (helios/src/frontend/images/mod.rs and orientation.rs (not opened)). On http::generate's preparation path, the only image-decoding caller is describe_images (helios/src/server/request.rs:1120-1233), which already wraps check_batch, decode_encoded, describe_image, geometry, and check_budget with .map_err(|error| error.admission_context(AdmissionError::Image)) (request.rs:1141, 1194, 1196, 1208, 1230), and crate::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 at helios/src/server/http.rs:127-129 and its synthetic unit-test row at helios/src/server/http.rs:758-761.
  2. Replace the 21-field hand-rebuilt HttpState literal in phase_tests.rs:8452-8480 with Arc::get_mut on http_state_for:
    • make_state builds base = http_state_for(fixture, sender, None, &[]) and then copies all 21 fields of HttpState solely to override images, max_body_bytes, and context_hint, duplicating http_state_for (phase_tests.rs:4273-4295) and inviting merge conflicts with any PR adding an HttpState field.
    • Follow the existing pattern at helios/src/server/runtime/phase_tests.rs:5086-5087: mutate let mut state = http_state_for(fixture, sender, None, &[]); via let s = Arc::get_mut(&mut state).unwrap(); to set only max_body_bytes, context_hint, and images.

Nits

Dropped on verification