{"record":{"id":"aedfbffbe05b9598","repo":"astrid-runtime/astrid","slug":"var-key-was-supplied-more-than-once","errorCode":null,"errorMessage":"--var '{key}' was supplied more than once","messagePattern":"--var '(.+?)' was supplied more than once","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-cli/src/commands/capsule/install.rs","lineNumber":71,"sourceCode":"#[derive(Debug, Clone, Default)]\npub(super) struct ManualInstallOptions {\n    pub(super) yes: bool,\n    pub(super) approve_untrusted: bool,\n    pub(super) vars: HashMap<String, String>,\n}\n\nimpl ManualInstallOptions {\n    fn from_cli(yes: bool, approve_untrusted: bool, items: &[String]) -> anyhow::Result<Self> {\n        let mut vars = 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() {\n                bail!(\"--var has an empty key (got {item:?})\");\n            }\n            if vars.insert(key.to_string(), value.to_string()).is_some() {\n                bail!(\"--var '{key}' was supplied more than once\");\n            }\n        }\n        Ok(Self {\n            yes,\n            approve_untrusted,\n            vars,\n        })\n    }\n}\n\n#[derive(Clone, Copy)]\npub(crate) struct OfflineCapsuleProvenance<'a> {\n    pub(crate) original_source: &'a str,\n    pub(crate) resolved_ref: Option<&'a str>,\n    pub(crate) signer: Option<&'a str>,\n    pub(crate) signature: Option<&'a str>,\n}\n","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-cli/src/commands/capsule/install.rs#L53-L89","documentation":"`from_cli` collects `--var` items into a `HashMap`; `vars.insert` returns `Some(old)` when the key already existed, and that triggers this bail. Duplicate keys in variable overrides are rejected instead of being silently overwritten, so the effective variable set is unambiguous.","triggerScenarios":"Passing the same key twice on the command line: `--var FOO=1 --var FOO=2`; a loop in a script emitting a `--var` twice; two sources of flags (config + shell) both adding the same key.","commonSituations":"Scripts accumulating `--var` flags in an array where a key appears in two entries; copy-paste duplication of flags; build tooling appending default vars that collide with user-supplied ones.","solutions":["Remove or deduplicate the repeated `--var` entries so each key appears once.","Keep the last intended value only: `--var FOO=2`.","If both values are needed under different names, rename one key (e.g. `FOO` vs `FOO_ALT`).","In scripts, build a unique key map before assembling the CLI invocation."],"exampleFix":"// before\n--var FOO=1 --var FOO=2\n// after\n--var FOO=2","handlingStrategy":"validation","validationCode":"fn dedup_vars(items: &[String]) -> Result<std::collections::HashMap<String, String>, String> {\n    let mut map = std::collections::HashMap::new();\n    for item in items {\n        let (k, v) = item.split_once('=')\n            .ok_or_else(|| format!(\"bad --var {item:?}\"))?;\n        if map.insert(k.to_string(), v.to_string()).is_some() {\n            return Err(format!(\"duplicate --var key: {k}\"));\n        }\n    }\n    Ok(map)\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"supplied more than once\") =>\n        eprintln!(\"A --var key was repeated; keep only the final intended value.\"),\n    other => other.expect(\"install failed\"),\n}","preventionTips":["Deduplicate --var flags in scripts before assembling the command line.","Keep one source of truth for default vars to avoid collisions with user flags.","Use a map/dict in tooling rather than appending raw flags.","Grep your wrapper scripts for repeated keys before running installs."],"tags":["cli","validation","duplicate-argument"],"backgroundTag":"conflicting-config-options","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"}