{"record":{"id":"0272941eb5279c79","repo":"astrid-runtime/astrid","slug":"publish-wasm-into-the-system-content-catalog","errorCode":null,"errorMessage":"publish WASM into the system content catalog","messagePattern":"publish WASM into the system content catalog","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-capsule-install/src/wasm.rs","lineNumber":70,"sourceCode":"\n    if !wasm_path.exists() || wasm_path.extension().and_then(|e| e.to_str()) != Some(\"wasm\") {\n        return Ok(None);\n    }\n\n    let bytes = std::fs::read(&wasm_path)\n        .with_context(|| format!(\"failed to read WASM binary: {}\", wasm_path.display()))?;\n\n    let hash = blake3::hash(&bytes).to_hex().to_string();\n    if let Some(storage) = storage {\n        let name = ContentName::new(format!(\"bin/{hash}.wasm\"))\n            .context(\"construct system WASM catalog name\")?;\n        storage\n            .content()\n            .put_streaming_batch(\n                &StateOwner::System,\n                [ContentIngest::new(name, Cursor::new(bytes.clone()))],\n            )\n            .map_err(|error| anyhow::anyhow!(error))\n            .context(\"publish WASM into the system content catalog\")?;\n    } else {\n        let bin_dir = home.bin_dir();\n        std::fs::create_dir_all(&bin_dir)?;\n\n        let store_path = bin_dir.join(format!(\"{hash}.wasm\"));\n        if !store_path.exists() {\n            // Atomic temp-and-rename so a concurrent installer racing on\n            // identical bytes never observes a half-written file.\n            // A UUID-suffixed temp name is essential — `process::id()`\n            // alone would collide between sibling tokio tasks in the\n            // same daemon (gateway processes admin requests in parallel\n            // after the bus-direct refactor).\n            let tmp = bin_dir.join(format!(\"{hash}.tmp.{}\", uuid::Uuid::new_v4().simple()));\n            std::fs::write(&tmp, &bytes)\n                .with_context(|| format!(\"failed to write temp file: {}\", tmp.display()))?;\n            match std::fs::rename(&tmp, &store_path) {\n                Ok(()) => {},","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-capsule-install/src/wasm.rs#L52-L88","documentation":"Wraps a storage error from put_streaming_batch when publishing compiled WASM bytes into the system-level content catalog (StateOwner::System) during content_address_wasm. The catalog write is the content-addressed publish path; if it fails the whole install fails, since installs require catalog-backed WASM rather than loose bin files.","triggerScenarios":"install_from_local_path_internal calls content_address_wasm while storage.content().put_streaming_batch(&StateOwner::System, ...) returns an Err — the underlying content store rejected the streaming ingest of the WASM bytes.","commonSituations":"Disk full or unwritable content store directory; permission problems on the system content catalog path; corrupted content-store metadata; storage backend (e.g. network or object store) unavailable; WASM file larger than an ingest size limit.","solutions":["Check disk space and write permissions on the content store directory used by StateOwner::System","Run the install again — transient backend failures during streaming ingest are the common case","Inspect the wrapped storage error (this message is only the anyhow context; the source error chain has the real cause)","Verify the store backend is reachable/healthy if using a remote or custom content store"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// before install: ensure system content store is writable and has space\nlet dir = content_store_root(StateOwner::System);\nlet meta = std::fs::metadata(&dir).map_err(|e| format!(\"store unreachable: {e}\"))?;\nassert!(meta.len() < free_disk_space(dir)? - wasm_bytes.len());","typeGuard":null,"tryCatchPattern":"match content_address_wasm(&storage, &bytes) {\n    Err(e) if is_transient_storage(&e) => {\n        std::thread::sleep(BACKOFF);\n        content_address_wasm(&storage, &bytes).context(\"retry publish failed\")\n    }\n    Err(e) => Err(e.context(\"publish WASM into the system content catalog\")),\n    Ok(h) => Ok(h),\n}","preventionTips":["Monitor disk space on the content-store volume before installs","Verify write permissions on the system content catalog directory","Retry transient backend failures with backoff instead of failing the install immediately"],"tags":["rust","storage","wasm","content-catalog"],"backgroundTag":"file-write-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"}