{"record":{"id":"fcacf2d97d2aad79","repo":"Hmbown/CodeWhale","slug":"header-name-cannot-be-empty","errorCode":null,"errorMessage":"header name cannot be empty","messagePattern":"header name cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/config/src/lib.rs","lineNumber":6579,"sourceCode":"        \"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    }\n    Some(\n        headers\n            .iter()\n            .map(|(name, value)| format!(\"{name}={value}\"))\n            .collect::<Vec<_>>()","sourceCodeStart":6561,"sourceCodeEnd":6597,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/config/src/lib.rs#L6561-L6597","documentation":"parse_http_headers parses header pairs in the form name=value (e.g. from provider header config) and inserts them into a map. The library throws this error when the part before the '=' is empty after trimming, because an HTTP header name is required to carry the value. It is an input-validation guard, not a runtime fault.","triggerScenarios":"Calling any config API that routes through parse_http_headers with a pair like '=value', ' =value', or a trailing separator such as 'A=1;' where the empty segment's name is empty.","commonSituations":"Copy-pasting a header list from curl docs with stray separators, editing provider custom-header entries in config.toml and accidentally deleting the name, or building the header string programmatically by joining with '=' and including empty entries.","solutions":["Add a non-empty header name before the '=' in the offending pair","Remove stray/empty separators so every segment has the form name=value","Trim whitespace-only names — whitespace alone is also rejected"],"exampleFix":"// before\nheaders = \"=Bearer abc123\"\n// after\nheaders = \"Authorization=Bearer abc123\"","handlingStrategy":"validation","validationCode":"fn valid_header_pair(pair: &str) -> bool {\n    pair.split_once('=')\n        .map(|(n, _)| !n.trim().is_empty())\n        .unwrap_or(false)\n}","typeGuard":"fn is_header_pair(s: &str) -> Option<(&str, &str)> {\n    s.split_once('=')\n        .filter(|(n, _)| !n.trim().is_empty())\n}","tryCatchPattern":"match parse_http_headers(&raw) {\n    Ok(headers) => headers,\n    Err(e) if e.to_string().contains(\"header name cannot be empty\") => {\n        eprintln!(\"fix the header pair: {e}\");\n        Default::default()\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Validate every name=value segment before joining into a header string","Never emit trailing separators when programmatically joining pairs","Log the full offending pair when building header config so mistakes are visible"],"tags":["config","http","headers","validation"],"backgroundTag":"empty-required-field","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"}