wasmerio/wasmer · error · anyhow::Error
Could not find package with hash '{h}'
Error message
Could not find package with hash '{h}' What it means
fetch_webc_package resolves a PackageIdent to a downloadable webc URL. When the ident is a content hash (PackageIdent::Hash), it looks up the package release via get_package_release; if the backend returns None, it bails with 'Could not find package with hash {h}'. Name/version idents use a different URL construction and don't hit this path.
Source
Thrown at lib/backend-api/src/query.rs:777
/// Load a webc package from the registry.
///
/// NOTE: this uses the public URL instead of the download URL available through
/// the API, and should not be used where possible.
pub async fn fetch_webc_package(
client: &WasmerClient,
ident: &PackageIdent,
default_registry: &Url,
) -> Result<Container, anyhow::Error> {
let url = match ident {
PackageIdent::Named(n) => Url::parse(&format!(
"{default_registry}/{}:{}",
n.full_name(),
n.version_or_default()
))?,
PackageIdent::Hash(h) => match get_package_release(client, &h.to_string()).await? {
Some(webc) => Url::parse(&webc.webc_url)?,
None => anyhow::bail!("Could not find package with hash '{h}'"),
},
};
let data = client
.client
.get(url)
.header(reqwest::header::USER_AGENT, &client.user_agent)
.header(reqwest::header::ACCEPT, "application/webc")
.send()
.await?
.error_for_status()?
.bytes()
.await?;
from_bytes(data).context("failed to parse webc package")
}
/// Fetch app templates.View on GitHub (pinned to 8c4b9ee9d3)
Solutions
- Verify the hash against `wasmer package publish` output or the registry web UI and re-copy it.
- Resolve the package by name+version instead of hash (PackageIdent::Named) to fetch the latest release.
- Re-publish the artifact if it was never pushed or was deleted, then use the new hash.
- Confirm the client points at the registry that actually hosts this hash.
Example fix
// before
let url = fetch_webc_package(&client, &PackageIdent::Hash(h)).await?;
// after
let url = match fetch_webc_package(&client, &PackageIdent::Hash(h.clone())).await {
Ok(u) => u,
Err(_) => fetch_webc_package(&client, &PackageIdent::Named(PackageId::new("ns/pkg", Some(version)))).await?,
}; Defensive patterns
Strategy: try-catch
Try / catch
match fetch_webc_package(&client, &PackageIdent::Hash(h)).await {
Ok(url) => url,
Err(e) if e.to_string().contains("Could not find package with hash") => {
// fall back to name+version resolution or surface a clear 'unknown hash' error
fetch_webc_package(&client, &named_ident).await
}
Err(e) => return Err(e),
}; Prevention
- Copy hashes directly from publish output/registry UI, never retype them
- Pin by name+version when the exact hash is not guaranteed to exist
- Re-publish artifacts that were deleted and update pinned hashes
When it happens
Trigger: Calling fetch_webc_package with PackageIdent::Hash where the hash does not correspond to any published package release on the registry (unknown, unpublished, or malformed-but-parseable hash).
Common situations: Hash copied from another registry/environment; package deleted or re-published so the old hash is gone; hash referencing a locally built artifact never pushed; typos when pinning by hash.
Related errors
- cron job '{cron_job}' not found
- user agent must not be empty
- invalid value for {} - expected 0/false|1/true: '{other}'
- invocation start must not be after end
- invalid node type returned
AI-assisted analysis of wasmerio/wasmer@8c4b9ee9d3 (2026-09-01).
Data as JSON: /api/errors/df38f9ad132cbd07.
Report an issue: GitHub.