astrid-runtime/astrid · error
unexpected response from kernel: {body:?}
Error message
unexpected response from kernel: {body:?} What it means
`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.
Source
Thrown at crates/astrid-cli/src/commands/secret.rs:358
args.key, principal, capsule
))
);
Ok(ExitCode::SUCCESS)
}
async fn run_list(args: &ListArgs) -> Result<ExitCode> {
let principal = context::resolve_agent(args.agent.as_deref())?;
let format = ValueFormat::parse(&args.format);
let mut client = crate::admin_client::connect_as_active_agent().await?;
let body = client
.request(AdminRequestKind::EnvList {
principal,
capsule: None,
})
.await?;
let body = crate::admin_client::into_result(body)?;
let AdminResponseBody::EnvList(entries) = body else {
anyhow::bail!("unexpected response from kernel: {body:?}");
};
let mut keys = entries
.into_iter()
.map(secret_key_from_entry)
.collect::<Vec<_>>();
keys.sort_by(|a, b| a.capsule.cmp(&b.capsule).then_with(|| a.key.cmp(&b.key)));
if !format.is_pretty() {
emit_structured(&keys, format)?;
return Ok(ExitCode::SUCCESS);
}
if keys.is_empty() {
println!("{}", Theme::info("(no secrets stored)"));
return Ok(ExitCode::SUCCESS);
}
println!(
"{:<24} {:<32} {:<12} {}",
"CAPSULE".bold(),View on GitHub (pinned to affd8760f4)
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.
Example fix
// before
let AdminResponseBody::EnvList(entries) = body else {
anyhow::bail!("unexpected response from kernel: {body:?}");
};
// after
let AdminResponseBody::EnvList(entries) = body else {
anyhow::bail!("unexpected response from kernel: {body:?} (CLI/daemon version mismatch?)");
}; Defensive patterns
Strategy: try-catch
Type guard
fn is_env_list(body: &AdminResponseBody) -> bool { matches!(body, AdminResponseBody::EnvList(_)) } Try / catch
let body = crate::admin_client::into_result(body)?;
let AdminResponseBody::EnvList(entries) = body else {
eprintln!("kernel replied with an unexpected body; is the daemon up to date?");
bail!("unexpected response from kernel: {body:?}");
}; Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.
Related errors
- unexpected response from kernel: {other:?}
- unexpected daemon metadata response: {other:?}
- daemon returned an unexpected status response
- unexpected response from kernel: {other:?}
- unexpected response from kernel: {other:?}
AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09).
Data as JSON: /api/errors/aa360dd66142905d.
Report an issue: GitHub.