Final review report · NVIDIA/hyperflare-inference #603

Raw Markdown for agents: https://autobot.eidonix.com/p/eaeefc41-574f-48ae-b946-f0cafc3f4924.md

Recommendation: Changes Requested

This PR fixes a real operator-facing diagnostic gap on Hub 404 lookup failures with low merge risk and zero hot-path or concurrency impact, and it places the error context at the right call site (resolve_primary_target, avoiding double-prefixing refresh_model_at). However, the current diff adds 22 lines of unused typed-error boilerplate (RevisionLookupError / Error::source()), restricts annotation strictly to HTTP 404 while leaving HTTP 401/403 (which Hugging Face returns for private or nonexistent repositories) unnamed, and omits test coverage for the -tp1 fallback-exhausted path highlighted in the description. Simplifying the wrapper to format!(...).into(), widening it to ApiError (or explicitly scoping 404-only behavior), and adding a -tp1 fallback-exhausted test will make this a cleaner, smaller, and complete fix.

Merge Risk

Level: Low

Walkthrough

Pre-merge Checks

Blockers

None.

Should Fix

  1. HTTP 401/403 (and other Hub lookup errors) remain unnamed (flare/src/hub.rs:3427-3441, :8603, :8620-8622):

    • As flare/src/identity.rs:91-95 documents, Hugging Face returns HTTP 401/403 for a repository that does not exist or is not public — the other half of the diagnostic ambiguity cited from #489 — yet resolve_primary_target filters strictly to ureq::Error::StatusCode(404). Even in the PR's own test (flare/src/hub.rs:8603), ("gb10", 401) still surfaces without owner/model@gb10.
    • Fix: Annotate any ApiError returned by resolve_revision (e.g., if error.is::<ApiError>()), which keeps cancellation errors (flare/src/hub.rs:125) untouched, covers 401/403/404/5xx/network lookup failures uniformly, removes the duplicated 404 match guard (:3382-3383 vs :3430-3431), and lets :8620-8622 assert owner/model@{revision} for the 401 case too. (If 404-only scoping is strictly intentional, narrow the PR title accordingly and add an explicit negative assertion for the 401 case.)
  2. -tp1 fallback-exhausted path is untested and reports only the requested revision (flare/src/hub.rs:3381-3393, :3433-3437, :8603):

    • When repo.revision() matches tp1_revision_alias (flare/src/hub.rs:3363-3365, e.g., gb10) and both gb10 and gb10-tp1 return 404 inside resolve_revision, resolve_primary_target formats repo.revision() (gb10). Because the retry message at :3388 is log::info! (hidden in default CLI output), the surfaced error omits that gb10-tp1 was also attempted — slightly at odds with the PR description's "attempted repository@revision to the final HTTP 404". Neither ("gb10-tp1", 404) nor ("custom", 404) in permanent_resolution_failures_are_not_retried (:8603) exercises tp1_revision_alias.
    • Fix: Add a fixture test case where both gb10 and gb10-tp1 return 404, pinning the exact expected error text. Either include the fallback alias in the diagnostic when tried (e.g., cannot resolve owner/model@gb10 (also tried gb10-tp1): ...) or clarify in the PR description that the requested revision is reported (matching refresh_model_at at flare/src/hub.rs:2280).

Subtract / Simplify

  1. Delete RevisionLookupError and use format!(...).into() (flare/src/hub.rs:3398-3441):
    • RevisionLookupError (22 lines plus Display and std::error::Error impls) exists only to expose Error::source(), which nothing in flare/ or flare-cli/ reads: flare/src/hub.rs:29 erases errors to Box<dyn std::error::Error>, the CLI prints Display (flare-cli/src/main.rs:64), and Orbit flattens to String (flare-cli/src/orbit/agent.rs:135, flare-cli/src/orbit/controller.rs:2534-2546). Every other contextual wrapper in flare/src/hub.rs (:2280, :2651, :2658, :3297, :5516-5520) uses format!(...).into().
    • Replacing :3398-3441 with a direct map_err (combined with Should Fix #1):
      let info = resolve_revision(api, repo, progress).map_err(|error| {
          if error.is::<ApiError>() {
              format!("cannot resolve {}@{}: {error}", repo.url(), repo.revision()).into()
          } else {
              error
          }
      })?;
      
      produces the identical rendered message (retaining HTTP 404) while cutting ~25 lines of boilerplate and unused abstraction (AGENTS.md:188-190).

Nits

Dropped on verification