{"record":{"id":"6ab5c8ecb8001a2c","repo":"astrid-runtime/astrid","slug":"unexpected-capsule-metadata-response-other","errorCode":null,"errorMessage":"unexpected capsule metadata response: {other:?}","messagePattern":"unexpected capsule metadata response: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-cli/src/commands/init_grant.rs","lineNumber":305,"sourceCode":"/// 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,\n                    capsule.version,","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-cli/src/commands/init_grant.rs#L287-L323","documentation":"When the kernel replies to GetCapsuleMetadata with a response that is neither CapsuleMetadata nor Error, the CLI treats it as a protocol violation and bails with a debug dump of the unexpected variant. This indicates the kernel/CLI speak different protocol versions or the response was routed incorrectly.","triggerScenarios":"client.request(KernelRequest::GetCapsuleMetadata) resolves to some KernelResponse variant other than CapsuleMetadata or Error.","commonSituations":"Mismatched CLI and kernel versions where the kernel maps the request to a different response type; a kernel bug returning a generic/empty response for this request; middleware or proxy altering the response.","solutions":["Upgrade (or align) the CLI and kernel so GetCapsuleMetadata returns CapsuleMetadata.","Restart the kernel process and retry.","Inspect the {other:?} debug output to identify which variant was returned and trace why.","Report/patch the kernel handler if a new response type must be supported by the CLI."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// pre-flight protocol check\nmatch client.request(KernelRequest::Ping).await? {\n    KernelResponse::Pong => {},\n    other => eprintln!(\"kernel protocol mismatch: {other:?}\"),\n}","typeGuard":"fn is_capsule_metadata(r: &KernelResponse) -> bool {\n    matches!(r, KernelResponse::CapsuleMetadata(_))\n}","tryCatchPattern":"match request_metadata(&mut client).await {\n    Ok(entries) => Ok(entries),\n    Err(e) if e.to_string().contains(\"unexpected capsule metadata response\") => {\n        eprintln!(\"kernel/CLI version mismatch: {e}\");\n        Err(e)\n    }\n    Err(e) => Err(e),\n}","preventionTips":["Match CLI and kernel versions during upgrades.","Add a protocol/version handshake before API calls.","Cover all KernelResponse variants in tests.","Log unexpected variants verbatim for bug reports."],"tags":["kernel","protocol-mismatch","unexpected-response"],"backgroundTag":"unexpected-response-shape","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"}