Review — PR #603 "Report the repository and revision on Hub lookup errors"
Lens: Correctness, Contracts & System-Level Consequences. Head a3ec4b6, base main, one file: flare/src/hub.rs (+41/−1). All citations below were re-verified against the PR head in this session (diff at pr_diff, resolver at flare/src/hub.rs:3374-3449, test at :8601-8625).
Key findings
- The message names the requested revision, not the revision whose 404 was actually surfaced. The
-tp1fallback (hub.rs:3387-3390) runs insideresolve_revision, before the wrap at:3433-3437, which rebuilds the reference from the originalrepo. Whengb10404s andgb10-tp1also 404s, the operator is toldcannot resolve ORG/MODEL@gb10. Major. - A private or absent repository (HTTP 401/403) is still unnamed.
flare/src/identity.rs:91-95states in-repo that "huggingface.co answers 401 for a repository that does not exist or is not public"; the wrapper matches onlyStatusCode(404), and the test fixture deliberately runs a 401 case with no assertion. So the distinction #489 actually worried about (missing revision vs private/absent repository) is only half served. Major. - Only one of
resolve_revision's two callers is wrapped.refresh_model_at(hub.rs:2279-2280) keeps flattening the error to aString,scan_revisions(:2171) still swallows 404s, and the PR adds nodocs/TODO.txtentry althoughAGENTS.md:57-58routes unresolved defects there — the path #489's reviewer chose. Major. - The wrap depends on an unstated invariant (the boxed error still downcasts to a directly-boxed
ApiError), duplicates the resolver's 404 predicate byte for byte, and has no test for the fallback-exhausted text or for continuation in the non-404 cases. Minor. - Correctness, safety, concurrency and platform parity are clean. No lock, queue, shared state, buffering, metric span, wire/captured-graph/public contract, flag, default, dependency, or on-disk format is touched; the wrapper runs once, after the acquisition has already failed, off every hot path. The new type is private (
hub.rs:3398-3419) and the test lives in the un-cfg(unix)pub(crate) mod tests(hub.rs:5776-5777) using onlyString/format!, so there is no Unix/Windows gap. Nothing here needs design or performance evidence, so #210 does not apply.
Area 1 — Correctness, safety & platform parity
Finding 1 (Major): the diagnostic reports the requested revision, not the revision that produced the surfaced 404
flare/src/hub.rs:3381-3393 — the fallback decides and runs before the wrapper:
let info = match with_transient_retry(|| api.repo(repo.clone()).info()) {
Err(ApiError::RequestError(error))
if matches!(error.as_ref(), ureq::Error::StatusCode(404))
&& tp1_revision_alias(revision) =>
{
check_cancel(progress)?;
let alias = format!("{revision}-tp1");
log::info!("Hugging Face revision {revision} returned 404, trying {alias}");
let repo = Repo::with_revision(repo.url(), RepoType::Model, alias);
with_transient_retry(|| api.repo(repo.clone()).info())?
flare/src/hub.rs:3427-3441 — the context is rebuilt from the caller's repo, which still carries the original revision:
let info = resolve_revision(api, repo, progress).map_err(|source| {
if matches!(
source.downcast_ref::<ApiError>(),
Some(ApiError::RequestError(error))
if matches!(error.as_ref(), ureq::Error::StatusCode(404))
) {
Box::new(RevisionLookupError {
repository: repo.url(),
revision: repo.revision().to_owned(),
source,
})
Concrete impact: for a gb10 alias whose repository publishes only gb10-tp1 (or neither), the surfaced reference — the second lookup, Repo::with_revision(repo.url(), …, alias) at :3389 — is never named; the message says cannot resolve ORG/MODEL@gb10. That is the case the PR's own evidence fixture walks and the case #598 keeps enlarging: helios/src/core/naming.rs:15 now declares pub const PLATFORMS: [&str; 19], which widens the tp1_revision_alias predicate at flare/src/hub.rs:3363-3365 (revision.starts_with("gb") && PLATFORMS.contains(&revision)). The PR text says it adds "the attempted repository@revision to the final HTTP 404"; for the alias case the attempted reference and the reported one differ, and the operator's next step (hf reflects which branch exists) is misdirected. Secondary effect: the only trace of the first attempt is log::info! at :3388, which is not in the default CLI output.
Fix: have resolve_revision own the context, so it can report what it finally attempted — e.g. return the tried revision alongside RepoInfo, or construct the wrapped error in the -tp1 arm with cannot resolve ORG/MODEL@gb10 (also tried gb10-tp1). At minimum, reword the PR claim to "requested revision".
Finding 2 (Major): the absent/private-repository case — the other half of #489's ambiguity — stays a bare status
flare/src/identity.rs:91-95 records the Hub's own policy in this crate:
// huggingface.co answers 401 for a repository that does not exist or is not public.
Fetched::Status(status @ (401 | 403)) => {
return Ok(Resolution::Unreachable(format!(
"HTTP {status}, the repository does not exist or is not public"
)));
The wrapper matches only StatusCode(404) (hub.rs:3430-3431), and the resolver's fallback guard also requires 404 (:3383), so a 401/403 from core resolution passes through untouched: the operator sees the ApiError's bare status text with no owner/model@revision. The new test encodes exactly this gap — flare/src/hub.rs:8603 keeps a 401 case in the loop, and :8619-8622 asserts the repository string only under if status == 404:
for (revision, status) in [("gb10", 401), ("gb10-tp1", 404), ("custom", 404) {
...
assert!(error.contains(&status.to_string()), "{error}");
if status == 404 {
assert!(error.contains(&format!("owner/model@{revision}")), "{error}");
}
Impact: the PR's benefit statement — "An operator can identify the reference involved in the failure from the error message" — is false for private/typo'd/absent repositories, which is precisely one of the two branches #489 says an operator cannot currently tell apart. The result is an asymmetric diagnostic where the revision failure is annotated and the repository failure is not, so a 404 still reads as more information-rich than a 401 for no user-facing reason.
Fix: wrap ApiError::RequestError(StatusCode(401 | 403)) as well (the status still speaks for itself; only the reference is added), or narrow the PR's benefit sentence to "a missing revision". If policy is to annotate 404 only, say so in the description and assert the non-annotation in the test so the choice is deliberate rather than incidental.
Finding 3 (Minor): the 404 predicate is duplicated and the wrap rests on an unstated invariant
The predicate at hub.rs:3427-3432 is a byte-for-byte copy of the resolver's own arm at :3382-3384, and it is the first ApiError downcast in flare (the other downcasts in the crate are PublisherKeyRequired: hub.rs:6965, :7038, controller.rs:1306). It works only because resolve_revision propagates ApiError straight into Box<dyn Error> (type Result<T> = … Box<dyn std::error::Error>, hub.rs:29) without an intermediate format!/map_err. The very style already used on the sibling path — hub.rs:2280, .map_err(|error| format!("cannot check {}@{revision} for updates: {error}; …")) — silently disables the new message, with no compile error and no failing test.
Fix: match Err(ApiError::RequestError(error)) directly inside resolve_revision's existing match (:3381) and return the wrapped error from both arms; no downcast, no duplicated predicate, and the invariant disappears.
What is sound (no finding)
- No concurrency or system-level consequence. The wrapper runs once, after the acquisition has already failed; it allocates two
Strings and touches no lock, queue, cache, file or shared/coalesced state. HTTP 404 is classified permanent bytransient_hub_error(hub.rs:5460-5472: only408 | 429 | 500..=599retry), so the wrap cannot interact with the retry loop or amplify failures. - No failure-propagation blast radius. The wrapped message embeds the original
ApiError'sDisplay(hub.rs:3409-3411), so downstream text checks that look for the status code still match — the pre-existing assertion at:8619(error.contains(&status.to_string())) passes before and after, and the phrase-matching classifiercontent_failure(:5497-5505) cannot be tripped by the new prefix. - No platform parity gap. The test is in the un-
cfg(unix)pub(crate) mod tests(hub.rs:5776-5777) and uses onlyString/format!; the changed code is not platform-gated. - No metric/rate/admission-pricing span change. No rate, latency or admission metric samples this code path, so the span check is not applicable.
- No public or wire contract change.
RevisionLookupError(hub.rs:3398-3419) is private; no flag, default, dependency, on-disk format, exported core, or captured-graph contract moves.
Area 2 — Unintended system-level consequences
None found, and I checked the specific hazards named in the brief. The change is reachable only from resolve_primary_target (hub.rs:3421), itself reached from fetch_primary_with_progress (:3480) on the acquisition path; it adds no work to any successful request, so the uncontended, uncontended-partial-hit and small-repo paths are byte-identical to main. There is no per-request or per-file loop involvement (the wrapper runs at most once per acquisition), no memory retention (the two Strings live as long as the error), no disk I/O, and no interaction with the -tp1 fallback ordering invariant that recently merged work depends on (resolve_revision:3381-3392 is unchanged). It does not reverse or interact with #598's widened PLATFORMS; it only makes the resulting 404s readable (see Finding 1 for the caveat that the alias itself is not named).
Area 3 — Architecture, contracts & charter compliance
Finding 4 (Major): the same context belongs in resolve_revision, and the residue is unrecorded
resolve_revision (hub.rs:3374-3396) has two callers. Only resolve_primary_target (:3427) is wrapped. The second, the update check, flattens the error to a String and loses the cause chain:
flare/src/hub.rs:2279-2280:
let info = resolve_revision(&api, &repo, None)
.map_err(|error| format!("cannot check {}@{revision} for updates: {error}; the local version is unchanged (use --offline to skip the check)", origin.repository))?;
The third revision-lookup path never gains a reference either: RevisionClient::revision (hub.rs:2130-2151) keeps returning the bare ureq::Error::StatusCode(404) from its own fallback (:2141-2146), and scan_revisions drops the error outright at hub.rs:2171 (let Ok(remote) = self.revision(&key.0, &key.1) else { continue; };), feeding the background revision scan driven from flare/src/controller.rs:2637 and the per-origin check at :2649.
Meanwhile AGENTS.md:57-58 is explicit:
Record unresolved defects, unrun checks, and pending measurements in docs/TODO.txt, not in design documents.
A docs/TODO.txt search for hub|404|revision|diagnost matches only line 306 (release-workflow runner), i.e. there is no entry for the diagnosed defect — the disposition #489's reviewer (original-el8, CHANGES_REQUESTED) asked for. The PR body never states the scoping either ("primary core resolution" implies it but leaves the reader to infer that flare models update checks and Orbit's background scan stay opaque).
Impact: charter-wise this is the wrong-layer pattern the repo calls out (AGENTS.md, "Solve the right problem in the right place") — the shared resolver is where both callers would get the context for free, and the typed ApiError is available there without a downcast (Finding 3). Practically, an operator diagnosing an update-time failure (the path with the least other information: no progress output, --offline not obviously relevant) still gets only cannot check … : … StatusCode(404), and the background scan gives nothing at all.
Fix: build the context inside resolve_revision so both callers inherit it (the update check then also keeps the cause chain instead of a flattened String), and add a one-line docs/TODO.txt entry naming the remaining opaque path (RevisionClient::revision / scan_revisions) with its close condition. If the maintainer prefers to keep the change acquisition-only, record that residue in docs/TODO.txt in this PR and say so in the description.
No owner sign-off required
Nothing in the change touches a wire/proto contract, a captured-graph op contract, or a public type, so the owner-approval gates in the charter ("Captured-graph op contracts") do not apply. It is also not a global behavioral/default change: only the stderr text of an already-failing acquisition moves.
Area 4 — Tests & claim accuracy
Finding 5 (Minor): the cause chain is attached but unobservable — the description's "cause" claim is structural only
The new type exposes the original error both inside Display (hub.rs:3409-3411) and through Error::source() (:3415-3418):
impl std::error::Error for RevisionLookupError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
Some(self.source.as_ref())
}
}
But the only consumers on this path never walk the chain: the CLI prints eprintln!("Error: {error}") (flare-cli/src/main.rs:64), Orbit's agent flattens with error.to_string() (flare-cli/src/orbit/agent.rs:135), and Orbit's controller prefixes only the node name (flare-cli/src/orbit/controller.rs:2534-2535, format!("{node}: {error}")). So "Attach the original Hub error as the cause" (:3415-3418) changes nothing an operator can see; the visible improvement comes entirely from Display embedding the source. That is fine as engineering, but the description should say the rendered message carries the context and the chain is for programmatic callers — otherwise a reviewer will look for a source()-walking consumer that does not exist.
Finding 6 (Minor): test coverage does not pin the behavior the description claims
The added assertion (hub.rs:8620-8622) covers only the plain single-lookup 404. Nothing asserts:
- the fallback-exhausted text (
gb10→gb10-tp1, both 404) — the case that Finding 1 shows is mislabeled, and for which fixtures already exist:blackwell_revision_alias_installs_and_refreshes_the_pinned_core(hub.rs:12631-12641) andmodel_refresh_failed_update_keeps_default(:6358-6371); - that the 401 case stays unprefixed (Finding 2) — currently true but unpinned, so a later "fix everything" change is silent;
- that non-404 errors keep their prior text, which is the stated intent of the
if matches!guard.
Fix: add ("gb10", 404) with both routes 404 asserting the message names gb10-tp1 (or whatever the chosen wording is), and assert !error.contains("cannot resolve") for the 401 case.
Finding 7 (Minor): evidence claims are author-run and unverifiable
The description claims "the strengthened HTTP fixture test failed on the baseline", "both resolution failure tests passed", "the eight tests selected by --lib revision", "242 passed, 4 ignored" in release on Linux ARM64, and git diff --cached --check clean. There are no CI checks on a3ec4b6, so all of it rests on the author's word. The disclosed lockfile caveat is real and correctly disclosed: flare/Cargo.lock:598-600 pins deepseek-recipe 6d09e9be… while helios/Cargo.toml:35-37 pins 70be62f3…, so the suite was run against a temporarily realigned checkout, and the description says so. The baseline-failure claim is nonetheless consistent with the diff: the string cannot resolve does not exist on main, so the new assertion at :8620-8622 cannot pass there. What the description does not mention is that the end-to-end operator-visible path through Orbit is unverified — accurately noted as "The complete Orbit CLI workflow was not run", which is the right disclosure.
Fix: mark the suite counts as author-run on a realigned temporary lockfile, and (preferably) let CI run on the head before merge.
Open questions / what I could not find
- Is reporting the requested revision acceptable? No maintainer statement exists that the requested revision is the intended reference; the
-tp1fallback being invisible in the message is the direct consequence of placing the wrap outsideresolve_revision(Finding 1). - Is 401/403 deliberately out of scope? The test keeps a 401 fixture and does not assert on it, which reads as incidental rather than decided (Finding 2).
- Why
resolve_primary_targetrather thanresolve_revision? Nothing in the description explains the placement, and the resolver is the only site where the typedApiErroris available without a downcast (Findings 3 and 4). - Is the
RevisionClient::revisionbare 404 (hub.rs:2130-2151) intentionally left out, given it is the path the update check and Orbit's background scan depend on? No comment, nodocs/TODO.txtentry, no cross-link back to #489. - No issue or TODO entry records this defect; the only source is #489, an open docs PR by another contributor, whose reviewer asked for a
docs/TODO.txtrecord — not answerable from the record whether this PR is meant to satisfy that instruction. - Whether CI will run on this head at all — no checks exist on
a3ec4b6and none could be found; nothing in the repo mechanically blocks the PR.