{"record":{"id":"84a2dab0f4f540aa","repo":"astrid-runtime/astrid","slug":"unexpected-daemon-response-other-84a2da","errorCode":null,"errorMessage":"unexpected daemon response: {other:?}","messagePattern":"unexpected daemon response: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-cli/src/dispatch.rs","lineNumber":469,"sourceCode":"        astrid_core::kernel_api::KernelResponse::Success(_) => {\n            if purge {\n                let principal = crate::principal::current();\n                let entries =\n                    commands::capsule::install_headless::list_env_entries(&principal, &name)?;\n                for entry in entries {\n                    if matches!(entry.scope, astrid_core::kernel_api::EnvStorageScope::Agent) {\n                        commands::capsule::install_headless::delete_env_entry(\n                            &principal, &name, &entry.key, entry.kind,\n                        )?;\n                    }\n                }\n            }\n            eprintln!(\"Removed '{name}'.\");\n        },\n        astrid_core::kernel_api::KernelResponse::Error(message) => {\n            anyhow::bail!(\"daemon rejected capsule removal: {message}\");\n        },\n        other => anyhow::bail!(\"unexpected daemon response: {other:?}\"),\n    }\n    Ok(ExitCode::SUCCESS)\n}\n\nasync fn dispatch_mcp(command: McpCommands) -> Result<ExitCode> {\n    if !matches!(command, McpCommands::Gc) {\n        commands::daemon::validate_runtime_admission()?;\n    }\n    match command {\n        McpCommands::Serve {\n            workspace,\n            request_timeout: _,\n        } => commands::mcp::serve(None, workspace.as_deref()).await,\n        McpCommands::Attach { workspace } => {\n            commands::mcp::attach(None, workspace.as_deref()).await\n        },\n        McpCommands::Gateway => commands::mcp::gateway(None).await,\n        McpCommands::Ready { format } => commands::mcp::ready(None, &format).await,","sourceCodeStart":451,"sourceCodeEnd":487,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-cli/src/dispatch.rs#L451-L487","documentation":"dispatch_capsule_remove handles the daemon's response to a capsule removal request. It only expects a success variant (printing \"Removed '<name>'\") or KernelResponse::Error; any other KernelResponse variant falls into this catch-all bail, meaning the daemon answered with a response type the CLI did not anticipate for this operation.","triggerScenarios":"Calling `astrid capsule remove` when the daemon replies with a KernelResponse variant other than the removal-success or Error variant — e.g. a protocol mismatch where the CLI binary and daemon are different versions, or the daemon misroutes another command's response to this request.","commonSituations":"Running an older CLI against a newer daemon (or vice versa) after a protocol change; a buggy daemon returning a wrong variant; concurrent requests whose responses are crossed.","solutions":["Ensure the CLI and daemon are built from the same version (`astrid --version`, restart the daemon).","Inspect the debug payload in the message to identify which KernelResponse variant was returned and report/match it.","Add an explicit match arm for the unexpected variant in dispatch_capsule_remove, or update the astrid-core protocol types.","Restart the daemon and retry the removal to rule out a transient misrouted response."],"exampleFix":"// before\nother => anyhow::bail!(\"unexpected daemon response: {other:?}\"),\n// after\nKernelResponse::NotFound(msg) => anyhow::bail!(\"capsule not found: {msg}\"),\nother => anyhow::bail!(\"unexpected daemon response: {other:?}\"),","handlingStrategy":"try-catch","validationCode":"let status = std::process::Command::new(\"astrid\").args([\"--version\"]).output()?;\nlet cli_v = String::from_utf8_lossy(&status.stdout);\n// ensure daemon version matches cli_v before issuing capsule remove","typeGuard":"fn is_expected_response(r: &KernelResponse) -> bool {\n    matches!(r, KernelResponse::Ok(_)) || matches!(r, KernelResponse::Error(_))\n}","tryCatchPattern":"match dispatch_capsule_remove(cmd) {\n    Ok(code) => code,\n    Err(e) if e.to_string().starts_with(\"unexpected daemon response\") => {\n        eprintln!(\"CLI/daemon protocol mismatch: {e:#}; restart daemon or upgrade CLI\");\n        ExitCode::FAILURE\n    }\n    Err(e) => { eprintln!(\"{e:#}\"); ExitCode::FAILURE }\n}","preventionTips":["Keep CLI and daemon installed from the same build/version.","Restart the daemon after upgrading astrid-core.","Match every KernelResponse variant you care about explicitly and keep the catch-all last.","Log the full debug payload ({other:?}) when reporting bugs."],"tags":["cli","daemon","protocol-mismatch","ipc"],"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"}