{"record":{"id":"7f1c2fb7118e05ed","repo":"Kuberwastaken/claurst","slug":"invalid-env-var-format-expected-key-value","errorCode":null,"errorMessage":"Invalid env-var format '{}': expected KEY=VALUE","messagePattern":"Invalid env-var format '(.+?)': expected KEY=VALUE","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-rust/crates/core/src/feature_gates.rs","lineNumber":131,"sourceCode":"    }\r\n}\r\n\r\n// ---------------------------------------------------------------------------\r\n// Env-var parsing for --env KEY=VALUE arguments\r\n// ---------------------------------------------------------------------------\r\n\r\n/// Parse a slice of `\"KEY=VALUE\"` strings into a `HashMap`.\r\n///\r\n/// Returns an error if any entry lacks a `=` separator.\r\npub fn parse_env_vars(args: &[String]) -> anyhow::Result<HashMap<String, String>> {\r\n    let mut map = HashMap::new();\r\n    for entry in args {\r\n        if let Some(pos) = entry.find('=') {\r\n            let key = entry[..pos].to_string();\r\n            let value = entry[pos + 1..].to_string();\r\n            map.insert(key, value);\r\n        } else {\r\n            return Err(anyhow::anyhow!(\r\n                \"Invalid env-var format '{}': expected KEY=VALUE\",\r\n                entry\r\n            ));\r\n        }\r\n    }\r\n    Ok(map)\r\n}\r\n\r\n// ---------------------------------------------------------------------------\r\n// AWS region\r\n// ---------------------------------------------------------------------------\r\n\r\n/// Resolve the AWS region, checking `AWS_REGION` then `AWS_DEFAULT_REGION`,\r\n/// falling back to `\"us-east-1\"`.\r\npub fn get_aws_region() -> String {\r\n    std::env::var(\"AWS_REGION\")\r\n        .or_else(|_| std::env::var(\"AWS_DEFAULT_REGION\"))\r\n        .unwrap_or_else(|_| \"us-east-1\".to_string())\r","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/Kuberwastaken/claurst/blob/b0637c97ec34144387cbf2f74f65df6d16a6cef1/src-rust/crates/core/src/feature_gates.rs#L113-L149","documentation":"Thrown by `parse_env_vars` in src-rust/crates/core/src/feature_gates.rs when an entry in the input list contains no `=` character, so it cannot be split into KEY and VALUE. The parser requires every entry to be in KEY=VALUE form and fails fast on the first malformed entry.","triggerScenarios":"Passing a bare variable name without `=` (e.g. \"DEBUG\") or an empty/whitespace-only string to parse_env_vars; callers like parse_env_vars_basic forward user-supplied gate config entries verbatim.","commonSituations":"Config listing env var names to check for existence but written without `=VALUE`; copy-pasted settings where `=` was lost; YAML/TOML lists mixing names and KEY=VALUE pairs; trailing empty string from a split on ',' with a trailing comma.","solutions":["Rewrite the entry as KEY=VALUE (e.g. \"DEBUG=1\" instead of \"DEBUG\").","If the intent is only to assert an env var exists, use \"KEY=1\" or any placeholder value.","Trim the input list to remove empty strings caused by trailing separators.","Validate entries with `entry.contains('=')` before passing them to the parser."],"exampleFix":"// before\nparse_env_vars(&[\"DEBUG\", \"RUST_LOG=info\"])?;\n\n// after\nparse_env_vars(&[\"DEBUG=1\", \"RUST_LOG=info\"])?;","handlingStrategy":"validation","validationCode":"fn valid_env_entries(entries: &[String]) -> bool {\n    entries.iter().all(|e| !e.is_empty() && e.contains('='))\n}","typeGuard":"fn as_key_value(entry: &str) -> Option<(&str, &str)> {\n    let pos = entry.find('=')?;\n    Some((&entry[..pos], &entry[pos + 1..]))\n}","tryCatchPattern":"match parse_env_vars(&entries) {\n    Ok(map) => use(map),\n    Err(e) if e.to_string().contains(\"Invalid env-var format\") => {\n        // surface which entry was malformed to the user\n        report_bad_entry(&entries, &e);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Always write env entries as KEY=VALUE, even for existence checks (KEY=1).","Trim lists and drop empty strings before parsing.","Validate entries with entry.contains('=') at config-load time.","Never mix bare variable names with KEY=VALUE pairs in one list."],"tags":["env-var","parsing","validation","format"],"backgroundTag":"invalid-env-var-value","analyzedSha":"b0637c97ec34144387cbf2f74f65df6d16a6cef1","analyzedAt":"2026-09-10T00:24:58.650Z","contentChangedAt":"2026-09-10T00:24:58.650Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}