{"record":{"id":"aa360dd66142905d","repo":"astrid-runtime/astrid","slug":"unexpected-response-from-kernel-body-aa360d","errorCode":null,"errorMessage":"unexpected response from kernel: {body:?}","messagePattern":"unexpected response from kernel: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-cli/src/commands/secret.rs","lineNumber":358,"sourceCode":"            args.key, principal, capsule\n        ))\n    );\n    Ok(ExitCode::SUCCESS)\n}\n\nasync fn run_list(args: &ListArgs) -> Result<ExitCode> {\n    let principal = context::resolve_agent(args.agent.as_deref())?;\n    let format = ValueFormat::parse(&args.format);\n    let mut client = crate::admin_client::connect_as_active_agent().await?;\n    let body = client\n        .request(AdminRequestKind::EnvList {\n            principal,\n            capsule: None,\n        })\n        .await?;\n    let body = crate::admin_client::into_result(body)?;\n    let AdminResponseBody::EnvList(entries) = body else {\n        anyhow::bail!(\"unexpected response from kernel: {body:?}\");\n    };\n    let mut keys = entries\n        .into_iter()\n        .map(secret_key_from_entry)\n        .collect::<Vec<_>>();\n\n    keys.sort_by(|a, b| a.capsule.cmp(&b.capsule).then_with(|| a.key.cmp(&b.key)));\n    if !format.is_pretty() {\n        emit_structured(&keys, format)?;\n        return Ok(ExitCode::SUCCESS);\n    }\n    if keys.is_empty() {\n        println!(\"{}\", Theme::info(\"(no secrets stored)\"));\n        return Ok(ExitCode::SUCCESS);\n    }\n    println!(\n        \"{:<24}  {:<32}  {:<12}  {}\",\n        \"CAPSULE\".bold(),","sourceCodeStart":340,"sourceCodeEnd":376,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-cli/src/commands/secret.rs#L340-L376","documentation":"`run_list` sends an `AdminRequestKind::EnvList` request and destructures the reply as `AdminResponseBody::EnvList(entries)`. Any other AdminResponseBody (including an embedded error already surfaced by into_result) triggers this bail with the body debug-printed. It is a response-shape guard for the list operation.","triggerScenarios":"Running `astrid secret list` when the kernel answers EnvList with a different AdminResponseBody variant — daemon/CLI version skew, a proxy answering on the admin socket, or a kernel that routes the request to a handler returning Success/Error instead.","commonSituations":"Daemon updated with a changed EnvList response shape while the CLI is stale; connecting to the wrong admin endpoint; middleware or tests returning a mock body of the wrong variant.","solutions":["Rebuild/update CLI and daemon to matching versions and restart the daemon.","Inspect the printed `{body:?}` to identify which variant actually came back and why.","Verify the admin socket points at the astrid kernel admin service.","Extend the match in run_list if the protocol intentionally gained a new response variant."],"exampleFix":"// before\nlet AdminResponseBody::EnvList(entries) = body else {\n    anyhow::bail!(\"unexpected response from kernel: {body:?}\");\n};\n// after\nlet AdminResponseBody::EnvList(entries) = body else {\n    anyhow::bail!(\"unexpected response from kernel: {body:?} (CLI/daemon version mismatch?)\");\n};","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"fn is_env_list(body: &AdminResponseBody) -> bool { matches!(body, AdminResponseBody::EnvList(_)) }","tryCatchPattern":"let body = crate::admin_client::into_result(body)?;\nlet AdminResponseBody::EnvList(entries) = body else {\n    eprintln!(\"kernel replied with an unexpected body; is the daemon up to date?\");\n    bail!(\"unexpected response from kernel: {body:?}\");\n};","preventionTips":["Deploy CLI and daemon as a matched pair (same release).","Restart the daemon after upgrades.","Confirm the admin endpoint hosts the astrid kernel.","Keep response-destructuring exhaustive; add tests for new AdminResponseBody variants."],"tags":["ipc","protocol-mismatch","unexpected-response","rust"],"backgroundTag":"unexpected-api-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"}