{"record":{"id":"0e5c2c5d12688db8","repo":"openai/codex","slug":"mcp-http-headers-helper-returned-an-invalid-header-0e5c2c","errorCode":null,"errorMessage":"MCP HTTP headers helper returned an invalid header value","messagePattern":"MCP HTTP headers helper returned an invalid header value","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"codex-rs/rmcp-client/src/http_headers.rs","lineNumber":401,"sourceCode":"                | \"origin\"\n                | \"proxy-connection\"\n                | \"referer\"\n                | \"te\"\n                | \"trailer\"\n                | \"transfer-encoding\"\n                | \"upgrade\"\n        ) {\n            return Err(anyhow!(\n                \"MCP HTTP headers helper returned a reserved header\"\n            ));\n        }\n        if parsed.contains_key(&name) {\n            return Err(anyhow!(\n                \"MCP HTTP headers helper returned duplicate header names\"\n            ));\n        }\n        let value = HeaderValue::from_str(&value)\n            .map_err(|_| anyhow!(\"MCP HTTP headers helper returned an invalid header value\"))?;\n        parsed.insert(name, value);\n    }\n    Ok(parsed)\n}\n\n#[cfg(test)]\n#[path = \"http_headers_tests.rs\"]\nmod tests;\n","sourceCodeStart":383,"sourceCodeEnd":410,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/rmcp-client/src/http_headers.rs#L383-L410","documentation":"Generic validation guard in the MCP HTTP headers helper: a header name/value pair produced by the helper could not be converted into a valid http::HeaderValue, meaning the value contains illegal bytes (non-visible ASCII, control characters, or non-ASCII) and the request cannot be sent with that header.","triggerScenarios":"Thrown at codex-rs/rmcp-client/src/http_headers.rs:401 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the MCP header helper configuration so the header value contains only visible ASCII characters","Trim or sanitize the header value before it reaches HeaderValue::from_str","Log the offending header name (not value) to identify the source of the invalid bytes"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}