{"record":{"id":"a9d4cf945413044a","repo":"astrid-runtime/astrid","slug":"var-has-an-invalid-key-got-key","errorCode":null,"errorMessage":"--var has an invalid key (got {key:?})","messagePattern":"--var has an invalid key \\(got (.+?)\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-cli/src/commands/capsule/install_daemon.rs","lineNumber":417,"sourceCode":"    }\n    if path.is_file() {\n        return astrid_capsule_install::read_archive_manifest(path)\n            .with_context(|| format!(\"read Capsule.toml from {}\", path.display()));\n    }\n    bail!(\"source path does not exist: {source}\")\n}\n\nfn validate_values(\n    manifest: &CapsuleManifest,\n    items: &[String],\n) -> anyhow::Result<Vec<DaemonEnvValue>> {\n    let mut parsed = HashMap::new();\n    for item in items {\n        let (key, value) = item\n            .split_once('=')\n            .ok_or_else(|| anyhow::anyhow!(\"--var must be KEY=VALUE (got {item:?})\"))?;\n        if key.is_empty() || key.contains('\\0') || key.contains(':') {\n            bail!(\"--var has an invalid key (got {key:?})\");\n        }\n        if parsed.insert(key.to_owned(), value.to_owned()).is_some() {\n            bail!(\"--var '{key}' was supplied more than once\");\n        }\n    }\n\n    let mut values = Vec::with_capacity(parsed.len());\n    for (key, value) in parsed {\n        let definition = manifest.env.get(&key).ok_or_else(|| {\n            anyhow::anyhow!(\n                \"--var names no [env] field in {}: {key}\",\n                manifest.package.name\n            )\n        })?;\n        let kind = if definition.env_type.eq_ignore_ascii_case(\"secret\") {\n            if value.len() > 64 * 1024 {\n                bail!(\"secret value for {key} exceeds 65536-byte limit\");\n            }","sourceCodeStart":399,"sourceCodeEnd":435,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-cli/src/commands/capsule/install_daemon.rs#L399-L435","documentation":"validate_values parses each --var item with split_once('='). After splitting, a key that is empty, contains a NUL byte, or contains a ':' is rejected. Keys must be non-empty, NUL-free, and colon-free to be valid env identifiers.","triggerScenarios":"Passing --var like `--var =value`, `--var bad:key=v`, or a key containing a NUL character to install_local_via_daemon_for_target_with_generation (or the tests vars_are_typed_and_manifest_bound / non_empty_values_do_not_attempt_resume_skip).","commonSituations":"Copy-pasting `KEY: value` style config into --var; extra whitespace producing an empty key; scripting that mangles the KEY=VALUE form.","solutions":["Rewrite the --var argument as plain KEY=VALUE with no colon or NUL in KEY.","Quote the argument in your shell so spaces don't split it: --var 'KEY=value'.","Check the [env] key spelling in Capsule.toml and use that exact key."],"exampleFix":"// before\n--var 'service:port=8080'\n// after\n--var 'service_port=8080'","handlingStrategy":"validation","validationCode":"const KEY_RE: &str = \"^[^:=\\0][^:\\0]*$\"; // key must be non-empty, no ':' or NUL\nassert!(key_chars.all(|c| c != ':' && c != '\\0'), \"invalid --var key\");","typeGuard":"fn valid_key(k: &str) -> bool { !k.is_empty() && !k.contains(':') && !k.contains('\\0') }","tryCatchPattern":"on this error, print the offending --var item and exit; fix the key format, don't retry blindly.","preventionTips":["Always quote --var 'KEY=value' in shell scripts.","Use keys matching the [env] section names in Capsule.toml.","Avoid colon-bearing names; prefer underscores."],"tags":["cli","validation","arguments","env"],"backgroundTag":"invalid-cli-argument","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"}