{"record":{"id":"64933d6079471540","repo":"astrid-runtime/astrid","slug":"message","errorCode":null,"errorMessage":"{message}","messagePattern":"\\{message\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-cli/src/commands/init_grant.rs","lineNumber":304,"sourceCode":"\n/// Reuse a fresh lock only when its installed state still verifies. A current\n/// distro id/version with stale or incomplete install provenance falls through\n/// to the normal checked install path so init can regenerate the lock.\npub(super) async fn validated_grant_set_for_reuse(\n    target: &PrincipalId,\n    locked: &[super::LockedCapsule],\n) -> Option<Vec<String>> {\n    if target != &crate::principal::current() {\n        return None;\n    }\n    let result = async {\n        let mut client = crate::socket_client::connect_kernel_for_workspace(None).await?;\n        let entries = match client\n            .request(astrid_core::kernel_api::KernelRequest::GetCapsuleMetadata)\n            .await?\n        {\n            astrid_core::kernel_api::KernelResponse::CapsuleMetadata(entries) => entries,\n            astrid_core::kernel_api::KernelResponse::Error(message) => bail!(message),\n            other => bail!(\"unexpected capsule metadata response: {other:?}\"),\n        };\n        let mut installed = Vec::with_capacity(locked.len());\n        for capsule in locked {\n            let expected = CapsuleId::new(capsule.name.clone())?;\n            let entry = entries\n                .iter()\n                .find(|entry| entry.name == capsule.name)\n                .ok_or_else(|| {\n                    anyhow::anyhow!(\n                        \"Distro.lock capsule '{}' is absent from the daemon registry\",\n                        capsule.name\n                    )\n                })?;\n            if !capsule.version.is_empty() && entry.version != capsule.version {\n                bail!(\n                    \"Distro.lock capsule '{}' expects version {}, but the daemon registry reports {}\",\n                    capsule.name,","sourceCodeStart":286,"sourceCodeEnd":322,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-cli/src/commands/init_grant.rs#L286-L322","documentation":"validated_grant_set_for_reuse asks the kernel for capsule metadata via KernelRequest::GetCapsuleMetadata. If the kernel responds with KernelResponse::Error, the CLI bails with the kernel-provided message. The message text is dynamic — it is whatever error the kernel reported.","triggerScenarios":"The GetCapsuleMetadata request to the kernel socket returns KernelResponse::Error(message); the bail propagates the kernel's own message string.","commonSituations":"Kernel cannot read its capsule registry; kernel-side permission or state errors while enumerating installed capsules; a kernel bug or version incompatibility producing an error response during grant-set reuse.","solutions":["Read the dynamic {message} text in the error — it states the kernel-side cause; address that directly.","Restart the kernel and retry the init/grant flow.","Verify the kernel and CLI versions are compatible.","If the kernel cannot serve metadata, fall back to a full install instead of grant reuse."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// check kernel connectivity before requesting metadata\nlet mut client = crate::socket_client::connect_kernel_for_workspace(None).await?;\n// if this fails, the kernel is down; restart before grant reuse","typeGuard":null,"tryCatchPattern":"match validated_grant_set_for_reuse().await {\n    Err(e) => { eprintln!(\"grant reuse failed: {e}; falling back to full install\"); full_install().await }\n    Ok(set) => Ok(set),\n}","preventionTips":["Restart the kernel when metadata requests error.","Keep kernel and CLI versions compatible.","Read the propagated kernel message for the specific cause.","Fall back to a full install when grant reuse is unavailable."],"tags":["kernel","ipc","dynamic-message"],"backgroundTag":"api-error-response","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"}