{"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":8597,"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":8579,"sourceCodeEnd":8615,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/ecc2/src/main.rs#L8579-L8615","documentation":"Thrown by parse_key_value_pairs when an entry does contain '=' but either the key or the value is empty after trimming whitespace. The parser requires both sides to be non-empty, so '=value', 'key=', or ' = ' are all rejected.","triggerScenarios":"Passing '--var =billing' (empty key), '--var component=' (empty value), or '--var = ' (both empty). Also when a template substitution leaves the value blank, e.g. '--var env=$ENV' where $ENV is unset.","commonSituations":"Empty environment variable expanded into the value; user clears a value by mistake; trailing '=' after editing; whitespace-only key or value.","solutions":["Provide a non-empty key and value: '--var component=billing'.","If the value comes from an env var, ensure it is set (e.g. 'export ENV=dev') or supply a default before running the command.","Strip accidental whitespace around the '=' so neither side is blank.","Inspect the failing value from the error message and correct that specific entry."],"exampleFix":"# before (ENV unset -> empty value)\necc2 run --var env=$ENV\n\n# after\nexport ENV=dev\necc2 run --var env=$ENV","handlingStrategy":"validation","validationCode":"fn is_nonempty_key_value(entry: &str) -> bool {\n    match entry.split_once('=') {\n        Some((k, v)) => !k.trim().is_empty() && !v.trim().is_empty(),\n        None => false,\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure env-derived values are set before expanding them into args.","Trim and check both halves of each key=value entry.","Add a CLI pre-flight check that rejects empty keys or values."],"tags":["cli","input-validation","parsing","key-value"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}