{"record":{"id":"c84ab61b280036c9","repo":"affaan-m/ECC","slug":"label-must-use-non-empty-key-value-form-value","errorCode":null,"errorMessage":"{label} must use non-empty key=value form: {value}","messagePattern":"(.+?) must use non-empty key=value form: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"ecc2/src/main.rs","lineNumber":8596,"sourceCode":"            priority: comms::TaskPriority::Normal,\n        },\n    )\n}\n\nfn parse_template_vars(values: &[String]) -> Result<BTreeMap<String, String>> {\n    parse_key_value_pairs(values, \"template vars\")\n}\n\nfn parse_key_value_pairs(values: &[String], label: &str) -> Result<BTreeMap<String, String>> {\n    let mut vars = BTreeMap::new();\n    for value in values {\n        let (key, raw_value) = value\n            .split_once('=')\n            .ok_or_else(|| anyhow::anyhow!(\"{label} must use key=value form: {value}\"))?;\n        let key = key.trim();\n        let raw_value = raw_value.trim();\n        if key.is_empty() || raw_value.is_empty() {\n            anyhow::bail!(\"{label} must use non-empty key=value form: {value}\");\n        }\n        vars.insert(key.to_string(), raw_value.to_string());\n    }\n    Ok(vars)\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n    use crate::config::Config;\n    use crate::session::store::StateStore;\n    use crate::session::{Session, SessionMetrics, SessionState};\n    use chrono::{Duration, Utc};\n    use std::fs;\n    use std::path::{Path, PathBuf};\n\n    struct TestDir {\n        path: PathBuf,","sourceCodeStart":8578,"sourceCodeEnd":8614,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/ecc2/src/main.rs#L8578-L8614","documentation":"This CLI argument parser splits each `--var`/env-style value on `=` and rejects entries whose key or value is empty, e.g. `=foo`, `bar=`, `=`, or `key=`. It is a validation guard ensuring every variable inserted into the map has a meaningful key and value.","triggerScenarios":"Passing a flag value like `--env PATH=` or `--set =value`; whitespace-only key or value such as `--env '  =  '` which trims to empty.","commonSituations":"Shell scripts building flags from environment variables where one variable is empty (`FOO=\"\"` produces `FOO=`); copy-pasting examples with placeholder values left blank; template expansion dropping a value.","solutions":["Ensure every variable is supplied as `KEY=value` with both parts non-empty.","Check upstream environment variables are set before composing the CLI args.","Quote the argument in your shell so `=` splitting behaves as intended and empty values fail loudly here rather than silently.","Remove entries with empty values entirely if the variable is intentionally unset."],"exampleFix":"// before\nmyapp run --env DEBUG=\n// after\nmyapp run --env DEBUG=1","handlingStrategy":"validation","validationCode":"fn validate_var(value: &str) -> Result<(), String> {\n    match value.split_once('=') {\n        Some((k, v)) if !k.trim().is_empty() && !v.trim().is_empty() => Ok(()),\n        _ => Err(format!(\"bad key=value: {value}\")),\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Filter out empty environment variables before building CLI args: `[ -n \"$FOO\" ] && args+=(\"--env\" \"FOO=$FOO\")`.","Quote variables in shell to avoid word-splitting surprises.","Test flag composition with `printf '%s\\\\n' \"${args[@]}\"` before invoking the binary."],"tags":["cli","validation","arguments"],"backgroundTag":"invalid-argument-format","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}