{"record":{"id":"4363e9712c8a20ef","repo":"xai-org/grok-build","slug":"invalid-header-format-header-expected-format","errorCode":null,"errorMessage":"Invalid header format: '{header}'. Expected format: 'Name: value'","messagePattern":"Invalid header format: '(.+?)'\\. Expected format: 'Name: value'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-pager/src/mcp_cmd.rs","lineNumber":454,"sourceCode":"    let mut env = HashMap::new();\n    for pair in pairs {\n        match pair.split_once('=') {\n            Some((key, value)) if !key.is_empty() => {\n                env.insert(key.to_string(), value.to_string());\n            }\n            _ => bail!(\n                \"Invalid environment variable format: '{pair}'. Environment variables should be added as: -e KEY1=value1 -e KEY2=value2\"\n            ),\n        }\n    }\n    Ok(env)\n}\n\nfn parse_headers(headers: &[String]) -> Result<HashMap<String, String>> {\n    let mut parsed = HashMap::new();\n    for header in headers {\n        let Some((name, value)) = header.split_once(':') else {\n            bail!(\"Invalid header format: '{header}'. Expected format: 'Name: value'\");\n        };\n        let name = name.trim();\n        if name.is_empty() {\n            bail!(\"Invalid header: '{header}'. Header name cannot be empty.\");\n        }\n        parsed.insert(name.to_string(), value.trim().to_string());\n    }\n    Ok(parsed)\n}\n\nfn looks_like_url(command: &str) -> bool {\n    command.starts_with(\"http://\")\n        || command.starts_with(\"https://\")\n        || command.starts_with(\"localhost\")\n}\n\n/// True for `KEY=value` shapes with a `[A-Za-z_][A-Za-z0-9_]*` key.\nfn looks_like_env_pair(s: &str) -> bool {","sourceCodeStart":436,"sourceCodeEnd":472,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-pager/src/mcp_cmd.rs#L436-L472","documentation":"`parse_headers` requires each --header value to contain a colon separating name and value, i.e. 'Name: value'. A header string without any ':' is rejected with this message. This keeps HTTP headers well-formed before they are attached to an HTTP/SSE server config.","triggerScenarios":"`--header 'Authorization Bearer x'` (missing colon), passing key=value style pairs instead of Name: value, or shell mangling that drops the colon.","commonSituations":"Reusing -e KEY=value syntax for headers, copying curl -H examples that used a different format, YAML/JSON-style header definitions pasted into the CLI.","solutions":["Use the 'Name: value' format: --header 'Authorization: Bearer <token>'.","Check that the colon survived shell quoting (it is not an = separated pair).","One --header flag per header."],"exampleFix":"// before\ngrok mcp add acme --transport http https://acme.example.com/mcp --header 'Authorization=Bearer x'\n// after\ngrok mcp add acme --transport http https://acme.example.com/mcp --header 'Authorization: Bearer x'","handlingStrategy":"validation","validationCode":"for h in headers {\n    assert!(h.contains(':'), \"header '{h}' must be 'Name: value'\");\n}","typeGuard":"fn is_well_formed_header(h: &str) -> bool { h.split_once(':').map_or(false, |(n, _)| !n.trim().is_empty()) }","tryCatchPattern":null,"preventionTips":["Use 'Name: value' colon format, not KEY=value.","Quote headers in the shell so the colon survives.","One --header flag per header."],"tags":["cli","mcp","http-headers","parsing"],"backgroundTag":"invalid-header-format","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}