Skip to content

Commit

Permalink
Error out when the only versions matching a constraint are archived
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-F-Bryan committed Jun 19, 2023
1 parent 7e40a93 commit e16952a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/wasix/src/runtime/resolver/wapm_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ impl Source for WapmSource {
Some(WapmWebQueryGetPackage { versions }) => versions,
None => return Ok(Vec::new()),
};
let mut archived_versions = Vec::new();

for pkg_version in versions {
tracing::trace!(?pkg_version, "checking package version");
Expand All @@ -171,6 +172,7 @@ impl Source for WapmSource {
pkg.version=%version,
"Skipping an archived version",
);
archived_versions.push(version);
continue;
}

Expand All @@ -188,6 +190,25 @@ impl Source for WapmSource {
}
}

if summaries.is_empty() {
match archived_versions.as_slice() {
[] => {
// looks like this package couldn't be satisfied at all.
}
[version] => {
anyhow::bail!(
"The only version satisfying the constraint, {version}, is archived"
);
}
[first, rest @ ..] => {
let num_others = rest.len();
anyhow::bail!(
"Unable to satisfy the request, {first}, and {num_others} are all archived"
);
}
}
}

Ok(summaries)
}
}
Expand Down

0 comments on commit e16952a

Please sign in to comment.