{"record":{"id":"fd1937df33abde08","repo":"astrid-runtime/astrid","slug":"var-names-no-env-field-in-capsule-id-key","errorCode":null,"errorMessage":"--var names no [env] field in {capsule_id}: {key}","messagePattern":"--var names no \\[env\\] field in (.+?): (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-cli/src/commands/capsule/install_headless.rs","lineNumber":27,"sourceCode":"use astrid_events::{AstridEvent, EventBus, EventMetadata, EventReceiver};\nuse astrid_types::Topic;\nuse astrid_types::ipc::{IpcMessage, IpcPayload, OnboardingFieldType};\n\nuse super::install_prompts::order_env_keys;\n\n/// Persist manifest configuration supplied to `capsule install --yes` without\n/// reading stdin. Existing values are preserved unless the operator explicitly\n/// supplies a replacement. Secret and text values use typed daemon control\n/// namespaces.\npub(crate) fn write_headless_env_fields(\n    env_defs: &HashMap<String, EnvDef>,\n    capsule_id: &str,\n    principal: &PrincipalId,\n    vars: &HashMap<String, String>,\n) -> anyhow::Result<()> {\n    for key in vars.keys() {\n        if !env_defs.contains_key(key) {\n            anyhow::bail!(\"--var names no [env] field in {capsule_id}: {key}\");\n        }\n    }\n\n    let existing = list_env_entries(principal, capsule_id)?;\n    let existing_keys: std::collections::HashSet<String> =\n        existing.into_iter().map(|entry| entry.key).collect();\n\n    for key in order_env_keys(env_defs) {\n        let def = &env_defs[&key];\n        let env_key = headless_env_key(&key);\n        let supplied = vars\n            .get(&key)\n            .cloned()\n            .or_else(|| std::env::var(&env_key).ok());\n        if supplied.is_none() && existing_keys.contains(&key) {\n            continue;\n        }\n        let resolved = supplied","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-cli/src/commands/capsule/install_headless.rs#L9-L45","documentation":"In headless (non-interactive) install, write_headless_env_fields validates every value passed via --var against the capsule manifest's declared [env] fields. A --var key that is not declared in the manifest is rejected, since headless mode cannot prompt for or invent undefined fields.","triggerScenarios":"finish_install invokes write_headless_env_fields with a --var key absent from the capsule's [env] definitions in its manifest.","commonSituations":"Typo in a --var key name; installing a newer/older capsule version where the env field was renamed or removed; copying --var flags from a different capsule's docs.","solutions":["Check the capsule manifest's [env] section (or its docs) for the exact field name and correct the --var spelling.","Remove the --var flag if the field is no longer declared in this capsule version.","Confirm you installed the capsule version you expect — field names may differ between versions."],"exampleFix":"// before\nastrid capsule install github:org/repo --var api-token=xxx   # manifest declares api_token\n// after\nastrid capsule install github:org/repo --var api_token=xxx","handlingStrategy":"validation","validationCode":"// validate --var keys against the manifest's [env] section before installing\nlet declared: HashSet<&str> = manifest.env.keys().map(|k| k.as_str()).collect();\nfor key in var_flags.keys() {\n    assert!(declared.contains(key.as_str()), \"undeclared --var: {key}\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Read the target capsule's manifest [env] section before writing --var flags.","Re-validate install scripts after upgrading the capsule version.","Keep var names in one place (config/CI variable) to avoid typos."],"tags":["capsule","install","env","cli"],"backgroundTag":"invalid-argument-value","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"}