{"record":{"id":"e7e27bbd68abd595","repo":"Hmbown/CodeWhale","slug":"invalid-header-pair-pair-expected-name-value","errorCode":null,"errorMessage":"invalid header pair '{pair}', expected name=value","messagePattern":"invalid header pair '(.+?)', expected name=value","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/config/src/lib.rs","lineNumber":6574,"sourceCode":"}\n\nfn parse_bool(raw: &str) -> Result<bool> {\n    match raw.trim().to_ascii_lowercase().as_str() {\n        \"1\" | \"true\" | \"yes\" | \"on\" | \"enabled\" => Ok(true),\n        \"0\" | \"false\" | \"no\" | \"off\" | \"disabled\" => Ok(false),\n        _ => bail!(\"invalid boolean '{raw}'\"),\n    }\n}\n\nfn parse_http_headers(raw: &str) -> Result<BTreeMap<String, String>> {\n    let mut headers = BTreeMap::new();\n    for pair in raw.trim().split(',') {\n        let pair = pair.trim();\n        if pair.is_empty() {\n            continue;\n        }\n        let Some((name, value)) = pair.split_once('=') else {\n            bail!(\"invalid header pair '{pair}', expected name=value\");\n        };\n        let name = name.trim();\n        let value = value.trim();\n        if name.is_empty() {\n            bail!(\"header name cannot be empty\");\n        }\n        if value.is_empty() {\n            continue;\n        }\n        headers.insert(name.to_string(), value.to_string());\n    }\n    Ok(headers)\n}\n\nfn serialize_http_headers(headers: &BTreeMap<String, String>) -> Option<String> {\n    if headers.is_empty() {\n        return None;\n    }","sourceCodeStart":6556,"sourceCodeEnd":6592,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/config/src/lib.rs#L6556-L6592","documentation":"parse_http_headers, a validation helper over the raw config string, splits the value on commas and requires each pair to contain '='; this error fires when one pair has no name=value form, meaning the offending header pair in the config value is malformed.","triggerScenarios":"Passing a header string where some fragment lacks '=', e.g. raw=\"Authorization: Bearer x\" (colon instead of equals) or \"Foo=bar,Baz\" (trailing bare name), or an unquoted value containing '=' handled correctly but a fragment like \"=value\" empty-name path next (empty name throws a different error; bare fragment throws this one).","commonSituations":"Using HTTP-style \"Name: value\" syntax instead of name=value; forgetting to quote values containing commas so the string splits mid-value; pasting a header block with newlines instead of comma separators.","solutions":["Write each header as name=value separated by commas: \"Authorization=Bearer x,X-Trace=abc\"","Replace colons between header name and value with '='","Quote or pre-encode values containing commas so they are not split into fragments"],"exampleFix":"// before\nheaders=\"Authorization: Bearer x\"\n\n// after\nheaders=\"Authorization=Bearer x\"","handlingStrategy":"validation","validationCode":"fn validate_header_string(raw: &str) -> Result<(), String> {\n    for pair in raw.trim().split(',') {\n        let pair = pair.trim();\n        if pair.is_empty() { continue; }\n        if !pair.contains('=') || pair.split('=').next().unwrap().trim().is_empty() {\n            return Err(format!(\"bad header pair: {pair}\"));\n        }\n    }\n    Ok(())\n}","typeGuard":"fn is_header_pair(fragment: &str) -> bool {\n    match fragment.trim().split_once('=') {\n        Some((n, _)) => !n.trim().is_empty(),\n        None => false,\n    }\n}","tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"invalid header pair\") => {\n        eprintln!(\"format headers as comma-separated name=value, not 'Name: value'\");\n    }\n    other => other?,\n}","preventionTips":["Always use name=value syntax with '=' between name and value","Quote env values containing commas so they are not split into bogus fragments","Validate the header string in the shell script before exporting it"],"tags":["config","parsing","http-headers","format"],"backgroundTag":"invalid-argument-format","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}