{"record":{"id":"8a3daaa1aa35c2b4","repo":"seanmonstar/warp","slug":"invalid-header-name-8a3daa","errorCode":null,"errorMessage":"invalid header name","messagePattern":"invalid header name","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/test.rs","lineNumber":231,"sourceCode":"    /// # Example\n    ///\n    /// ```\n    /// let req = warp::test::request()\n    ///     .header(\"accept\", \"application/json\");\n    /// ```\n    ///\n    /// # Panic\n    ///\n    /// This panics if the passed strings are not able to be parsed as a valid\n    /// `HeaderName` and `HeaderValue`.\n    pub fn header<K, V>(mut self, key: K, value: V) -> Self\n    where\n        HeaderName: TryFrom<K>,\n        HeaderValue: TryFrom<V>,\n    {\n        let name: HeaderName = TryFrom::try_from(key)\n            .map_err(|_| ())\n            .expect(\"invalid header name\");\n        let value = TryFrom::try_from(value)\n            .map_err(|_| ())\n            .expect(\"invalid header value\");\n        self.req.headers_mut().insert(name, value);\n        self\n    }\n\n    /// Set the remote address of this request\n    ///\n    /// Default is no remote address.\n    ///\n    /// # Example\n    /// ```\n    /// use std::net::{IpAddr, Ipv4Addr, SocketAddr};\n    ///\n    /// let req = warp::test::request()\n    ///     .remote_addr(SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080));\n    /// ```","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/seanmonstar/warp/blob/ff34d7213ed55ec342304aa7ff6ac4b351da9e66/src/test.rs#L213-L249","documentation":"Thrown inside warp::test::request().header(key, value) when the key string cannot be parsed as a valid HTTP HeaderName (e.g. contains characters outside the legal token set or is empty). The TryFrom<HeaderName> conversion fails and the code .expect(\"invalid header name\") panics, aborting the test process rather than returning a Result.","triggerScenarios":"Thrown at src/test.rs:231 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a valid HTTP header name: lowercase token characters only (letters, digits, and !#$%&'*+-.^_`|~), non-empty","Use constants from the http crate such as http::header::ACCEPT instead of hand-written strings","Pre-validate the header name with HeaderName::try_from(key) and handle the Err before calling .header()","Fix typos in header names, e.g. \"Accept\" is valid but names with spaces or invalid symbols are not"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ff34d7213ed55ec342304aa7ff6ac4b351da9e66","analyzedAt":"2026-09-09T16:57:46.316Z","contentChangedAt":"2026-09-09T16:57:46.316Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}