{"record":{"id":"a559e740e4e65bcc","repo":"astrid-runtime/astrid","slug":"unexpected-response-from-kernel-other","errorCode":null,"errorMessage":"unexpected response from kernel: {other:?}","messagePattern":"unexpected response from kernel: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-cli/src/commands/agent/mod.rs","lineNumber":472,"sourceCode":"\n/// Apply the parsed quota deltas: `QuotaGet` to pull the new agent's\n/// defaults, replay each requested field, single `QuotaSet`. A failure\n/// here leaves the agent in place with default quotas — operator can\n/// re-run `astrid quota set -a <name> ...` to retry.\nasync fn apply_initial_quotas(\n    client: &mut AdminClient,\n    principal: &PrincipalId,\n    updates: &[QuotaField],\n) -> Result<()> {\n    let body = client\n        .request(AdminRequestKind::QuotaGet {\n            principal: principal.clone(),\n        })\n        .await?;\n    let body = into_result(body)?;\n    let mut quotas = match body {\n        AdminResponseBody::Quotas(q) => q,\n        other => anyhow::bail!(\"unexpected response from kernel: {other:?}\"),\n    };\n    for field in updates {\n        match field {\n            QuotaField::Memory(b) => quotas.max_memory_bytes = *b,\n            QuotaField::Timeout(s) => quotas.max_timeout_secs = *s,\n            QuotaField::Storage(b) => quotas.max_storage_bytes = *b,\n            QuotaField::Processes(n) => quotas.max_background_processes = *n,\n        }\n    }\n    let body = client\n        .request(AdminRequestKind::QuotaSet {\n            principal: principal.clone(),\n            quotas,\n        })\n        .await?;\n    let _ = into_result(body)?;\n    println!(\n        \"  {}\",","sourceCodeStart":454,"sourceCodeEnd":490,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-cli/src/commands/agent/mod.rs#L454-L490","documentation":"apply_initial_quotas sends an Admin command (SetPrincipal with principal) to the kernel and expects an AdminResponseBody::Quotas reply. Any other reply variant indicates the kernel responded out of protocol — the request/response pairing broke — and the code bails with a debug-formatted view of the unexpected body. This guards the agent-creation flow (run_create) against silently misapplying quota updates.","triggerScenarios":"run_create → apply_initial_quotas when the kernel's reply to the quotas admin request is any AdminResponseBody variant other than Quotas (e.g. an error body, an ack for a different command, or a misrouted response).","commonSituations":"Kernel version skew with the CLI (different response schema); kernel returning an error-shaped body after a failed quota set; a concurrency/multiplexing bug pairing responses with the wrong requests; hitting a kernel that doesn't implement the quotas admin command.","solutions":["Check the debug dump ({other:?}) to see which body variant arrived and why.","Align CLI and kernel versions to the same release.","Check kernel logs for the original admin request failure; fix the underlying cause (e.g. invalid quota values, permission problem).","Retry agent creation after the kernel is healthy; if mispairing persists, report a protocol bug."],"exampleFix":"// before\nlet body = into_result(body)?;\nlet mut quotas = match body {\n    AdminResponseBody::Quotas(q) => q,\n    other => anyhow::bail!(\"unexpected response from kernel: {other:?}\"),\n};\n\n// after: surface kernel errors properly\nlet body = into_result(body)?;\nlet mut quotas = match body {\n    AdminResponseBody::Quotas(q) => q,\n    AdminResponseBody::Error(e) => anyhow::bail!(\"kernel rejected quota set: {e:?}\"),\n    other => anyhow::bail!(\"unexpected response from kernel: {other:?}\"),\n};","handlingStrategy":"type-guard","validationCode":"// after sending the admin request, verify the variant before use\nif !matches!(body, AdminResponseBody::Quotas(_)) {\n    eprintln!(\"kernel did not answer the quotas request: {body:?}\");\n}","typeGuard":"fn as_quotas(body: &AdminResponseBody) -> Option<&Quotas> {\n    match body {\n        AdminResponseBody::Quotas(q) => Some(q),\n        _ => None,\n    }\n}","tryCatchPattern":"match run_create(&opts).await {\n    Ok(agent) => { /* ... */ }\n    Err(e) if e.to_string().contains(\"unexpected response from kernel\") => {\n        eprintln!(\"protocol mismatch; check CLI/kernel versions and kernel logs\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Keep CLI and kernel on the same version channel.","Handle AdminResponseBody::Error variants explicitly upstream (into_result) so real errors don't masquerade as shape mismatches.","Log full request/response pairs for admin commands in development.","Check kernel feature support for the quotas admin command before calling.","Add protocol conformance tests for admin request/response pairing."],"tags":["kernel","ipc","protocol-mismatch","quotas","agent"],"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"}