{"record":{"id":"fd49c5a9a0299315","repo":"DioxusLabs/dioxus","slug":"http-method-specified-both-in-macro-and-in-attribu","errorCode":null,"errorMessage":"HTTP method specified both in macro and in attribute","messagePattern":"HTTP method specified both in macro and in attribute","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"packages/fullstack-macro/src/lib.rs","lineNumber":731,"sourceCode":"        }\n\n        // Disallow multiple query params if one is a catch-all\n        if query_params.iter().any(|param| param.catch_all) && query_params.len() > 1 {\n            return Err(syn::Error::new(\n                Span::call_site(),\n                \"Cannot have multiple query parameters when one is a catch-all\",\n            ));\n        }\n\n        if let Some(options) = route.oapi_options.as_mut() {\n            options.merge_with_fn(function)\n        }\n\n        let method = match (method_from_macro, route.method) {\n            (Some(method), None) => method,\n            (None, Some(method)) => method,\n            (Some(_), Some(_)) => {\n                return Err(syn::Error::new(\n                    Span::call_site(),\n                    \"HTTP method specified both in macro and in attribute\",\n                ));\n            }\n            (None, None) => {\n                return Err(syn::Error::new(\n                    Span::call_site(),\n                    \"HTTP method not specified in macro or in attribute\",\n                ));\n            }\n        };\n\n        Ok(Self {\n            method,\n            route_lit: route.route_lit,\n            path_params: route.path_params,\n            query_params,\n            oapi_options: route.oapi_options,","sourceCodeStart":713,"sourceCodeEnd":749,"githubUrl":"https://github.com/DioxusLabs/dioxus/blob/393d190a801ccb441d41923e232289b4f8a5c669/packages/fullstack-macro/src/lib.rs#L713-L749","documentation":"The route macros come in two flavors: method-specific wrappers (`#[get]`, `#[post]`, `#[put]`, `#[delete]`, `#[patch]` — see packages/fullstack-macro/src/lib.rs:150-171) that inject the method, and the generic `#[route]` that reads it from the attribute arguments. The compiler rejects a route where a method is supplied on both paths (lib.rs:727-733).","triggerScenarios":"`#[get(POST, \"/submit\")]` — the `get` wrapper supplies GET while the attribute also names POST; `#[post(\"/x\", method = PUT)]`-style double specification; converting a `#[route(GET, ...)]` handler to `#[get(...)]` and forgetting to delete the method token inside the parens.","commonSituations":"Copy-paste between handlers using different macro styles; changing the HTTP verb by editing the inner method instead of the macro name; examples mixing the two styles.","solutions":["If you use a method-named macro, remove the method from the attribute: `#[post(\"/submit\")]`.","If you want the method in the attribute, switch to the generic macro: `#[route(POST, \"/submit\")]`.","Re-check after verb changes that the method appears in exactly one of the two places."],"exampleFix":"// before\n#[get(POST, \"/submit\")]\nasync fn submit(form: Form<Data>) { ... }\n\n// after\n#[post(\"/submit\")]\nasync fn submit(form: Form<Data>) { ... }","handlingStrategy":"validation","validationCode":"# Fail when a method-named macro also carries a method token inside the parens\nrg -n '#\\[(get|post|put|delete|patch)\\(\\s*(GET|POST|PUT|DELETE|PATCH)\\b' src/ && \\\n  { echo 'ERROR: method specified both in macro name and attribute'; exit 1; } || true","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pick one style per file: either `#[get(\"/x\")]` everywhere or `#[route(GET, \"/x\")]` everywhere.","When changing a verb, change the macro name, not an inner token."],"tags":["dioxus","proc-macro","routes","http-method","compile-time"],"backgroundTag":null,"analyzedSha":"393d190a801ccb441d41923e232289b4f8a5c669","analyzedAt":"2026-08-16T11:27:45.815Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}