{"record":{"id":"fe88fbd667eccf0d","repo":"seanmonstar/warp","slug":"valid-method","errorCode":null,"errorMessage":"valid method","messagePattern":"valid method","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/test.rs","lineNumber":186,"sourceCode":"\nimpl RequestBuilder {\n    /// Sets the method of this builder.\n    ///\n    /// The default if not set is `GET`.\n    ///\n    /// # Example\n    ///\n    /// ```\n    /// let req = warp::test::request()\n    ///     .method(\"POST\");\n    /// ```\n    ///\n    /// # Panic\n    ///\n    /// This panics if the passed string is not able to be parsed as a valid\n    /// `Method`.\n    pub fn method(mut self, method: &str) -> Self {\n        *self.req.method_mut() = method.parse().expect(\"valid method\");\n        self\n    }\n\n    /// Sets the request path of this builder.\n    ///\n    /// The default is not set is `/`.\n    ///\n    /// # Example\n    ///\n    /// ```\n    /// let req = warp::test::request()\n    ///     .path(\"/todos/33\");\n    /// ```\n    ///\n    /// # Panic\n    ///\n    /// This panics if the passed string is not able to be parsed as a valid\n    /// `Uri`.","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/seanmonstar/warp/blob/ff34d7213ed55ec342304aa7ff6ac4b351da9e66/src/test.rs#L168-L204","documentation":"`warp::test::request().method(\"...\")` parses the given string into an `http::Method` and panics with \"valid method\" if it is not a valid HTTP method token (src/test.rs:186). This is documented as a deliberate panic in the test builder: invalid method names are test-authoring bugs, not runtime conditions. The panic occurs while constructing the test request, before the filter is exercised.","triggerScenarios":"Calling `.method(\"GET \")` (trailing space), `.method(\"get?\")` or any string containing characters outside the HTTP token grammar; empty strings; non-ASCII method names.","commonSituations":"Copy-pasted method names with whitespace or quotes; typos like \"GT\" (that one parses fine as a custom method, but \"GET;\" doesn't); generating methods dynamically from data files with stray characters.","solutions":["Use a valid uppercase method string: \"GET\", \"POST\", \"PUT\", \"DELETE\", \"PATCH\", \"HEAD\", \"OPTIONS\"","Pre-validate with `\"MYMETHOD\".parse::<http::Method>()` in test helpers before passing it to `.method()`","Trim the string and ensure it matches the HTTP token grammar (no spaces, separators, or non-ASCII)","For custom methods, verify the token is RFC 7230 compliant (ALPHA / DIGIT / \"!#$%&'*+-.^_`|~\")"],"exampleFix":"// before\nwarp::test::request().method(\"GET \").path(\"/health\");\n// after\nwarp::test::request().method(\"GET\").path(\"/health\");","handlingStrategy":"validation","validationCode":"fn assert_http_token(m: &str) {\n    assert!(m.parse::<http::Method>().is_ok(), \"'{}' is not a valid HTTP method\", m);\n}","typeGuard":"fn is_valid_method(m: &str) -> bool { m.parse::<http::Method>().is_ok() }","tryCatchPattern":null,"preventionTips":["Use exact standard method strings (\"GET\", \"POST\", ...) in tests","Trim strings coming from data files or tables before passing to .method()","Add a test-helper wrapper that parses the method first and panics with a clear message"],"tags":["testing","panic","http-method","validation"],"backgroundTag":"invalid-argument-format","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"}