{"record":{"id":"df38f9ad132cbd07","repo":"wasmerio/wasmer","slug":"could-not-find-package-with-hash-h","errorCode":null,"errorMessage":"Could not find package with hash '{h}'","messagePattern":"Could not find package with hash '(.+?)'","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"lib/backend-api/src/query.rs","lineNumber":777,"sourceCode":"\n/// Load a webc package from the registry.\n///\n/// NOTE: this uses the public URL instead of the download URL available through\n/// the API, and should not be used where possible.\npub async fn fetch_webc_package(\n    client: &WasmerClient,\n    ident: &PackageIdent,\n    default_registry: &Url,\n) -> Result<Container, anyhow::Error> {\n    let url = match ident {\n        PackageIdent::Named(n) => Url::parse(&format!(\n            \"{default_registry}/{}:{}\",\n            n.full_name(),\n            n.version_or_default()\n        ))?,\n        PackageIdent::Hash(h) => match get_package_release(client, &h.to_string()).await? {\n            Some(webc) => Url::parse(&webc.webc_url)?,\n            None => anyhow::bail!(\"Could not find package with hash '{h}'\"),\n        },\n    };\n\n    let data = client\n        .client\n        .get(url)\n        .header(reqwest::header::USER_AGENT, &client.user_agent)\n        .header(reqwest::header::ACCEPT, \"application/webc\")\n        .send()\n        .await?\n        .error_for_status()?\n        .bytes()\n        .await?;\n\n    from_bytes(data).context(\"failed to parse webc package\")\n}\n\n/// Fetch app templates.","sourceCodeStart":759,"sourceCodeEnd":795,"githubUrl":"https://github.com/wasmerio/wasmer/blob/8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5/lib/backend-api/src/query.rs#L759-L795","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before\nlet url = fetch_webc_package(&client, &PackageIdent::Hash(h)).await?;\n// after\nlet url = match fetch_webc_package(&client, &PackageIdent::Hash(h.clone())).await {\n    Ok(u) => u,\n    Err(_) => fetch_webc_package(&client, &PackageIdent::Named(PackageId::new(\"ns/pkg\", Some(version)))).await?,\n};","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match fetch_webc_package(&client, &PackageIdent::Hash(h)).await {\n    Ok(url) => url,\n    Err(e) if e.to_string().contains(\"Could not find package with hash\") => {\n        // fall back to name+version resolution or surface a clear 'unknown hash' error\n        fetch_webc_package(&client, &named_ident).await\n    }\n    Err(e) => return Err(e),\n};","preventionTips":["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"],"tags":["backend-api","not-found","package","webc","registry"],"backgroundTag":"package-not-found","analyzedSha":"8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5","analyzedAt":"2026-09-01T23:06:31.009Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}