{"record":{"id":"b9e2aeb6cab4fd61","repo":"astrid-runtime/astrid","slug":"unexpected-env-list-response-response","errorCode":null,"errorMessage":"unexpected env list response: {response:?}","messagePattern":"unexpected env list response: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-cli/src/commands/capsule/install_daemon.rs","lineNumber":110,"sourceCode":"        )?\n    };\n    install_local_via_daemon_for_target(source, &vars, &principal, None, authority).await\n}\n\nasync fn list_existing_keys(\n    principal: &PrincipalId,\n    capsule: &str,\n) -> anyhow::Result<std::collections::HashSet<String>> {\n    let mut client = crate::admin_client::connect_as_active_agent().await?;\n    let response = client\n        .request(AdminRequestKind::EnvList {\n            principal: principal.clone(),\n            capsule: Some(capsule.to_owned()),\n        })\n        .await?;\n    let response = crate::admin_client::into_result(response)?;\n    let AdminResponseBody::EnvList(entries) = response else {\n        bail!(\"unexpected env list response: {response:?}\");\n    };\n    Ok(entries.into_iter().map(|entry| entry.key).collect())\n}\n\n/// Install a local artifact into an explicit authenticated principal's\n/// durable registry. The kernel enforces whether the caller may select that\n/// target; this helper never opens the principal store itself.\npub(crate) async fn install_local_via_daemon_for_target(\n    source: &str,\n    vars: &[String],\n    target: &PrincipalId,\n    provenance: Option<CapsuleInstallProvenance>,\n    authority: CapsuleInstallAuthority,\n) -> anyhow::Result<InstalledCapsuleOutcome> {\n    install_local_via_daemon_for_target_with_generation(\n        source, vars, target, provenance, authority, None,\n    )\n    .await","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-cli/src/commands/capsule/install_daemon.rs#L92-L128","documentation":"list_existing_keys calls the daemon/admin EnvList API and destructures the response with `let AdminResponseBody::EnvList(entries) = response else`. If the admin client returns any other AdminResponseBody variant, it bails with the debug dump of the response. It guards against the server/client disagreeing on the reply shape for an env-list request.","triggerScenarios":"Calling install_local_via_daemon_outcome -> list_existing_keys when the daemon responds to an EnvList request with an error body, a differently-tagged AdminResponseBody variant, or a response from an incompatible daemon version.","commonSituations":"Daemon running an older/newer build with different response variants; request authenticated against the wrong principal/capsule so the daemon answers with an error; proxy or daemon returning a generic error body instead of EnvList.","solutions":["Inspect the debug dump of {response:?} in the message to see which AdminResponseBody variant actually came back.","Restart/upgrade the astrid daemon so its version matches the CLI.","Re-authenticate or verify the principal/capsule sent in the AdminRequest are correct.","Run `crate::admin_client::into_result` semantics in mind: if this keeps firing, file a bug since into_result should have already converted error bodies."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// before installing, check daemon/CLI versions match\nastrid daemon version && astrid --version","typeGuard":"if let AdminResponseBody::EnvList(entries) = response { /* use entries */ } else { /* handle unexpected shape */ }","tryCatchPattern":"match anyhow result: on Err(e) if e.to_string().contains(\"unexpected env list response\"), restart/upgrade the daemon and retry once; otherwise propagate.","preventionTips":["Keep CLI and daemon on the same release version.","Verify principal/capsule arguments before calling install.","Log the full response body when integrating with the daemon."],"tags":["unexpected-response","daemon","cli","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-14T05:17:10.506Z"}