{"record":{"id":"2f191599cef5b2e5","repo":"hasura/graphql-engine","slug":"http-method-0-not-supported","errorCode":null,"errorMessage":"HTTP method {0} not supported","messagePattern":"HTTP method (.+?) not supported","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/crates/plugins/pre-route-plugin/src/execute.rs","lineNumber":32,"sourceCode":"};\nuse serde_json::json;\nuse tracing_util::{\n    ErrorVisibility, SpanVisibility, Traceable, TraceableError, set_attribute_on_active_span,\n};\n\n#[derive(Debug, thiserror::Error)]\npub enum Error {\n    #[error(\"Error while making the HTTP request to the pre-parse plugin {0} - {1}\")]\n    ErrorWhileMakingHTTPRequestToTheHook(String, reqwest::Error),\n    #[error(\"Error while building the request for the pre-parse plugin {0} - {1}\")]\n    BuildRequestError(String, String),\n    #[error(\"Reqwest error: {0}\")]\n    ReqwestError(reqwest::Error),\n    #[error(\"Unexpected status code: {0}\")]\n    UnexpectedStatusCode(u16),\n    #[error(\"Error parsing the request: {0}\")]\n    PluginRequestParseError(serde_json::error::Error),\n    #[error(\"HTTP method {0} not supported\")]\n    UnsupportedHTTPMethod(String),\n    #[error(\"Invalid header name {0}\")]\n    InvalidHeaderName(String),\n    #[error(\"Invalid header value {0}\")]\n    InvalidHeaderValue(String),\n    #[error(\"Not found\")]\n    NotFound,\n    // Only used in the pre-route plugin handler function. Defined to ensure consistent\n    // response formatting in IntoResponse impl.\n    #[error(\"Cannot load pre-route plugins: {0}\")]\n    CannotLoadPlugins(String),\n}\n\nimpl TraceableError for Error {\n    fn visibility(&self) -> ErrorVisibility {\n        ErrorVisibility::Internal\n    }\n}","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/plugins/pre-route-plugin/src/execute.rs#L14-L50","documentation":"The pre-route hook returned a routing instruction whose HTTP method string is not supported by the executor — the {0} field contains the rejected method name. Only a known set of methods can be applied to the rewritten/routed request.","triggerScenarios":"The hook responds with an instruction to rewrite the request using a method like \"PATCH\", \"TRACE\", or a custom string that the executor's match does not handle.","commonSituations":"Hook written to forward arbitrary client methods; typo'd method name (\"GET \" with whitespace, lowercase mismatch); newer method support added to the hook but not the engine crate version in use.","solutions":["Fix the hook to only return methods the engine supports (GET, POST, PUT, DELETE, HEAD, OPTIONS as documented).","Normalize the method string (trim, uppercase) before returning it from the hook.","Upgrade the engine crate if a newer version added support for the method you need."],"exampleFix":"// before (hook)\n{\"method\": method_from_client} // may be \"patch\" or custom\n\n// after (hook)\nlet m = method_from_client.trim().to_uppercase();\nassert!(matches!(m.as_str(), \"GET\"|\"POST\"|\"PUT\"|\"DELETE\"|\"HEAD\"|\"OPTIONS\"));\n{\"method\": m}","handlingStrategy":"validation","validationCode":"const SUPPORTED: &[&str] = &[\"GET\",\"POST\",\"PUT\",\"DELETE\",\"HEAD\",\"OPTIONS\"];\nfn supported_method(m: &str) -> bool { SUPPORTED.contains(&m.trim().to_uppercase().as_str()) }","typeGuard":"fn is_supported_method(m: &str) -> bool {\n    matches!(m.trim().to_uppercase().as_str(), \"GET\"|\"POST\"|\"PUT\"|\"DELETE\"|\"HEAD\"|\"OPTIONS\")\n}","tryCatchPattern":"if let Error::UnsupportedHTTPMethod(m) = &e { tracing::warn!(\"hook sent unsupported method {m}; keeping original\"); }","preventionTips":["Normalize and allowlist methods in hook code before returning instructions.","Add unit tests for method handling in the hook.","Upgrade the engine crate when new method support is required."],"tags":["http","method","plugin","rust","pre-route-hook"],"backgroundTag":"unsupported-http-method","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}