{"record":{"id":"be96c7aa447107b0","repo":"astrid-runtime/astrid","slug":"unexpected-response-from-kernel-other-be96c7","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/audit.rs","lineNumber":85,"sourceCode":"struct AuditStatsOutput {\n    stats: AuditStats,\n    health: AuditHealth,\n}\n\n/// Dispatch an audit operator command through the kernel admin RPC.\npub(crate) async fn run(args: &AuditArgs) -> Result<ExitCode> {\n    match &args.command {\n        AuditCommand::Stats(args) => run_stats(args).await,\n        AuditCommand::Prune(args) => run_prune(args).await,\n        AuditCommand::Health(args) => run_health(args).await,\n    }\n}\n\nasync fn run_stats(args: &AuditStatsArgs) -> Result<ExitCode> {\n    let mut client = connect_as_active_agent().await?;\n    let stats = match into_result(client.request(AdminRequestKind::AuditStats).await?)? {\n        AdminResponseBody::AuditStats(stats) => stats,\n        other => bail!(\"unexpected response from kernel: {other:?}\"),\n    };\n    let health = match into_result(client.request(AdminRequestKind::AuditHealth).await?)? {\n        AdminResponseBody::AuditHealth(health) => health,\n        other => bail!(\"unexpected response from kernel: {other:?}\"),\n    };\n    let degraded = stats.degraded || health.degraded;\n    let format = ValueFormat::parse(&args.format);\n    if format.is_pretty() {\n        print_stats_pretty(&stats, &health);\n    } else {\n        emit_structured(&AuditStatsOutput { stats, health }, format)?;\n    }\n    Ok(if degraded {\n        ExitCode::from(2)\n    } else {\n        ExitCode::SUCCESS\n    })\n}","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-cli/src/commands/audit.rs#L67-L103","documentation":"In `run_stats` (crates/astrid-cli/src/commands/audit.rs:85), the CLI sends AdminRequestKind::AuditStats and pattern-matches the reply expecting AdminResponseBody::AuditStats. A different variant aborts with bail!. The guard keeps the stats command from operating on a body that lacks the audit statistics fields.","triggerScenarios":"The AuditStats admin request returns a non-AuditStats AdminResponseBody variant — kernel/CLI protocol skew, kernel answering with an error or status body, or a mis-routed admin reply.","commonSituations":"Audit subsystem disabled or reshaped in a newer kernel while the CLI expects AuditStats; admin socket connected to a service that does not implement AuditStats; version-mismatched deployment.","solutions":["Match CLI and kernel versions so AuditStats response shape agrees on both sides","Read the {other:?} variant in the error message to identify the actual body","Verify the audit subsystem is enabled in the kernel configuration","Confirm the admin client connects to the kernel implementing AdminRequestKind::AuditStats"],"exampleFix":"// before\nlet stats = match into_result(client.request(AdminRequestKind::AuditStats).await?)? {\n    AdminResponseBody::AuditStats(stats) => stats,\n    other => bail!(\"unexpected response from kernel: {other:?}\"),\n};\n// after\nlet stats = match into_result(client.request(AdminRequestKind::AuditStats).await?)? {\n    AdminResponseBody::AuditStats(stats) => stats,\n    other => bail!(\n        \"unexpected response from kernel (expected AuditStats, got {other:?}); \\\n         check CLI/kernel version match\"\n    ),\n};","handlingStrategy":"type-guard","validationCode":"// Confirm audit support exists before querying: kernel version/capability check.\n// e.g. ensure kernel >= version_with_audit_support before sending AdminRequestKind::AuditStats","typeGuard":"fn as_audit_stats(body: AdminResponseBody) -> Option<AuditStats> {\n    match body {\n        AdminResponseBody::AuditStats(s) => Some(s),\n    _ => None,\n    }\n}","tryCatchPattern":"match run_stats(&args).await {\n    Ok(code) => code,\n    Err(e) if e.to_string().contains(\"unexpected response from kernel\") => {\n        eprintln!(\"audit stats unavailable: {e:#}\");\n        ExitCode::from(2)\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Verify the kernel build has the audit subsystem enabled before using audit commands","Keep CLI and kernel on the same version","Capture the {other:?} variant dump in logs for post-mortem","Query AuditHealth first as a capability probe for audit support"],"tags":["cli","ipc","protocol-mismatch","audit"],"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"}