{"record":{"id":"89188e120e3a1876","repo":"astrid-runtime/astrid","slug":"read-wasm-from-system-catalog","errorCode":null,"errorMessage":"read WASM from system catalog","messagePattern":"read WASM from system catalog","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-capsule-install/src/wasm.rs","lineNumber":121,"sourceCode":"}\n\n/// Read one verified executable from the system-owned content catalog.\npub(crate) fn read_catalog_wasm(\n    storage: &RuntimePrincipalStore,\n    hash: &str,\n) -> anyhow::Result<Vec<u8>> {\n    let name = ContentName::new(format!(\"bin/{hash}.wasm\"))\n        .context(\"construct system WASM catalog name\")?;\n    let descriptor = storage\n        .content()\n        .describe(&StateOwner::System, &name)\n        .map_err(|error| anyhow::anyhow!(error))\n        .context(\"describe WASM in system catalog\")?\n        .ok_or_else(|| anyhow::anyhow!(\"WASM catalog entry is missing: bin/{hash}.wasm\"))?;\n    storage\n        .content()\n        .read_range(&StateOwner::System, &name, 0, descriptor.logical_bytes())\n        .map_err(|error| anyhow::anyhow!(error))\n        .context(\"read WASM from system catalog\")?\n        .ok_or_else(|| anyhow::anyhow!(\"WASM catalog entry has no readable bytes: bin/{hash}.wasm\"))\n}\n\n/// Verify that the system catalog entry for `expected` exists and hashes to\n/// its content-addressed name.\npub fn catalog_wasm_hash(\n    storage: &RuntimePrincipalStore,\n    expected: &str,\n) -> anyhow::Result<String> {\n    let actual = blake3::hash(&read_catalog_wasm(storage, expected)?)\n        .to_hex()\n        .to_string();\n    anyhow::ensure!(\n        actual == expected,\n        \"installed WASM integrity check failed: expected BLAKE3 {expected}, got {actual}\"\n    );\n    Ok(actual)","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-capsule-install/src/wasm.rs#L103-L139","documentation":"Wraps a storage error from content().read_range() when reading back the full byte range of a WASM catalog entry after a successful describe(). The descriptor exists but actually reading the bytes failed, so catalog_wasm_hash cannot compute the integrity digest.","triggerScenarios":"catalog_wasm_hash -> read_catalog_wasm: describe(&StateOwner::System, name) returns Some(descriptor), then read_range(&StateOwner::System, &name, 0, descriptor.logical_bytes()) returns Err.","commonSituations":"Underlying blob file deleted or truncated while the descriptor still exists (partial GC, interrupted write); filesystem read/permission errors; corrupt content-store index pointing at a missing chunk; descriptor reporting logical_bytes beyond what is physically stored.","solutions":["Re-publish the WASM into the catalog (re-run the install) to rewrite the missing/truncated blob","Inspect the wrapped storage error for the concrete filesystem/backend cause","Check the content store for orphaned descriptors and prune or repair them","Verify no concurrent GC/compaction is running while reads are in flight"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// sanity: descriptor and blob must both be readable\nlet d = storage.content().describe(&StateOwner::System, &name)?.ok_or(\"missing\")?;\nstorage.content().read_range(&StateOwner::System, &name, 0, d.logical_bytes())?\n    .ok_or(\"blob unreadable\")?;","typeGuard":null,"tryCatchPattern":"match catalog_wasm_hash(&storage, &expected) {\n    Err(e) if e.to_string().contains(\"read WASM from system catalog\") => {\n        // blob missing/truncated: republish and re-verify once\n        republish_wasm(&storage, &source_bytes)?;\n        catalog_wasm_hash(&storage, &expected)\n    }\n    other => other,\n}","preventionTips":["Avoid interrupting installs mid-ingest; interrupted writes leave descriptors without blobs","Keep GC/compaction from running concurrently with catalog reads","Monitor the content store for orphaned descriptors"],"tags":["rust","storage","wasm","content-catalog"],"backgroundTag":"file-read-failed","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}