{"record":{"id":"3b6e62299a95fddb","repo":"astrid-runtime/astrid","slug":"lifecycle-dispatch-failed-e","errorCode":null,"errorMessage":"lifecycle dispatch failed: {e}","messagePattern":"lifecycle dispatch failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-capsule-install/src/lifecycle.rs","lineNumber":304,"sourceCode":"            phase,\n            previous_version,\n            principal_context,\n        ))\n    } else {\n        tokio::task::block_in_place(|| {\n            handle.block_on(astrid_capsule::engine::wasm::run_lifecycle_for_principal(\n                cfg,\n                phase,\n                previous_version,\n                principal_context,\n            ))\n        })\n    };\n\n    drop(event_bus);\n    drop(owned_rt);\n\n    result.map_err(|e| anyhow::anyhow!(\"lifecycle dispatch failed: {e}\"))\n}\n\nfn lifecycle_kv_namespace(principal: &PrincipalId, capsule_id: &str) -> String {\n    format!(\"{principal}:capsule:{capsule_id}\")\n}\n\nfn lifecycle_home_root() -> Option<std::path::PathBuf> {\n    // Native PrincipalHome is a released import source, never a lifecycle\n    // authority. The engine mounts home:// only when its principal context\n    // carries the UID-bound AstridFilesystem store.\n    None\n}\n\nfn lifecycle_config_values(\n    principal_uid: Option<astrid_core::identity::PrincipalUid>,\n    kv_store: &Arc<dyn astrid_storage::KvStore>,\n    capsule_id: &str,\n    owned_rt: Option<&tokio::runtime::Runtime>,","sourceCodeStart":286,"sourceCodeEnd":322,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-capsule-install/src/lifecycle.rs#L286-L322","documentation":"run_lifecycle_in_scope joins the result of the actual lifecycle dispatch (hooks run on a dedicated runtime thread) and, if that future returned Err, wraps it as 'lifecycle dispatch failed: {e}' after tearing down the event bus and runtime. It is a top-level aggregator error: the inner error carries the real cause (hook failure, storage failure, etc.).","triggerScenarios":"Any failure inside the dispatched lifecycle future for install/update/remove hooks — e.g. a lifecycle command exits non-zero, a hook panics to an error, storage or event-bus setup inside the dispatch fails — surfaced through run_lifecycle / run_lifecycle_for_principal / run_lifecycle_for_principal_with_storage.","commonSituations":"A capsule's install or remove hook script fails (missing binary, bad exit code); a hook times out or the runtime is dropped mid-dispatch; storage backends are unavailable when hooks try to persist state.","solutions":["Read the inner error chained via anyhow's context/cause chain (print with {:#} or .source()) to find the real failing hook or subsystem.","Run the failing lifecycle hook command manually to reproduce and fix the underlying failure.","Verify the capsule's lifecycle hook definitions (Capsule.toml) point to existing, executable commands.","Check storage/secret backend availability for the principal scope before retrying."],"exampleFix":"// before\nmatch result {\n    Err(e) => eprintln!(\"failed\"),\n    Ok(_) => {}\n}\n// after\nif let Err(e) = result {\n    eprintln!(\"lifecycle failed: {e:#}\"); // full cause chain\n    for cause in e.chain().skip(1) {\n        eprintln!(\"  caused by: {cause}\");\n    }\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match run_lifecycle(&config, capsule_id, step) {\n    Ok(_) => {}\n    Err(e) => {\n        eprintln!(\"lifecycle dispatch failed: {e:#}\");\n        // inspect e.chain() to find the failing hook\n    }\n}","preventionTips":["Test each capsule's lifecycle hooks locally before publishing.","Print full anyhow cause chains ({e:#}) so the inner hook error is visible.","Ensure hook commands exist and are executable in the target environment."],"tags":["lifecycle","dispatch","hooks"],"backgroundTag":"invalid-state-transition","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}