{"record":{"id":"0eb3781c7a385bc8","repo":"astrid-runtime/astrid","slug":"unexpected-response-for-reloadcapsules-other","errorCode":null,"errorMessage":"unexpected response for ReloadCapsules: {other:?}","messagePattern":"unexpected response for ReloadCapsules: (.+?)","errorType":"http","errorClass":"GatewayError::Internal","httpStatus":500,"severity":"error","filePath":"crates/astrid-gateway/src/routes/system.rs","lineNumber":101,"sourceCode":"        (status = 204, description = \"Capsules reloaded.\"),\n        (status = 401, body = ErrorBody),\n        (status = 403, body = ErrorBody, description = \"Caller lacks `capsule:reload`.\"),\n    )\n)]\npub async fn reload_capsules(\n    State(state): State<Arc<GatewayState>>,\n    req: Request<axum::body::Body>,\n) -> GatewayResult<StatusCode> {\n    let caller = caller_from(&req)?.clone();\n    let client = state.kernel_client_for(&caller)?;\n    let resp = client\n        .request(KernelRequest::ReloadCapsules)\n        .await\n        .map_err(daemon_kernel_error)?;\n    match resp {\n        KernelResponse::Success(_) => Ok(StatusCode::NO_CONTENT),\n        KernelResponse::Error(msg) => Err(GatewayError::Forbidden { reason: msg }),\n        other => Err(GatewayError::Internal(anyhow::anyhow!(\n            \"unexpected response for ReloadCapsules: {other:?}\"\n        ))),\n    }\n}\n","sourceCodeStart":83,"sourceCodeEnd":106,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-gateway/src/routes/system.rs#L83-L106","documentation":"The gateway requested a capsule reload from the kernel and expected KernelResponse::Success(_) or Error, but received a different variant. The gateway treats this as an internal protocol violation and surfaces it as GatewayError::Internal including the unexpected variant in the message.","triggerScenarios":"reload_capsules() in crates/astrid-gateway/src/routes/system.rs sends KernelRequest::ReloadCapsules and matches only Success(_) and Error(msg); any other KernelResponse variant (e.g. AgentReadiness, CapsuleMetadata) reaches the catch-all arm.","commonSituations":"Kernel and gateway binaries at different versions after a partial deploy; the kernel handler for ReloadCapsules was changed to return a richer response type; bus reply correlation is misrouting a response from another in-flight request.","solutions":["Read the {other:?} variant in the message to identify the mismatched response","Rebuild and redeploy the gateway and kernel together so their KernelResponse enums agree","Confirm the kernel's ReloadCapsules handler returns KernelResponse::Success or KernelResponse::Error","Audit BusKernelClient request-id/reply matching if responses from other requests leak in"],"exampleFix":"// before: stale gateway binary against updated kernel\n// after: redeploy both from the same build\nsystemctl restart astrid-gateway astrid-daemon","handlingStrategy":"try-catch","validationCode":"match kernel_response {\n    KernelResponse::Success(_) | KernelResponse::Error(_) => Ok(()),\n    other => Err(format!(\"kernel version mismatch: got {other:?} for ReloadCapsules\")),\n}","typeGuard":"fn is_success(resp: &KernelResponse) -> bool {\n    matches!(resp, KernelResponse::Success(_))\n}","tryCatchPattern":"match client.request(KernelRequest::ReloadCapsules).await? {\n    KernelResponse::Success(_) => Ok(StatusCode::NO_CONTENT),\n    KernelResponse::Error(msg) => Err(GatewayError::Forbidden { reason: msg }),\n    other => { log::error!(\"kernel protocol mismatch: {other:?}\"); Err(GatewayError::Internal(anyhow::anyhow!(\"unexpected response for ReloadCapsules: {other:?}\"))) }\n}","preventionTips":["Keep gateway and daemon-kernel on identical versions and redeploy them together","Add exhaustive match arms (deny unknown variants) so compile-time checks catch enum drift","Cover ReloadCapsules with a gateway-to-kernel integration test"],"tags":["internal","protocol-mismatch","rpc"],"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-17T15:17:12.973Z"}