{"id":"e537fbb876672e13","repo":"actix/actix-web","slug":"multiple-paths-specified-there-should-be-only-one","errorCode":null,"errorMessage":"Multiple paths specified! There should be only one.","messagePattern":"Multiple paths specified! There should be only one\\.","errorType":"exception","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"actix-web-codegen/src/route.rs","lineNumber":45,"sourceCode":"        })?;\n\n        // verify that path pattern is valid\n        let _ = ResourceDef::new(path.value());\n\n        // if there's no comma, assume that no options are provided\n        if !input.peek(Token![,]) {\n            return Ok(Self {\n                path,\n                options: Punctuated::new(),\n            });\n        }\n\n        // advance past comma separator\n        input.parse::<Token![,]>()?;\n\n        // if next char is a literal, assume that it is a string and show multi-path error\n        if input.cursor().literal().is_some() {\n            return Err(syn::Error::new(\n                Span::call_site(),\n                r#\"Multiple paths specified! There should be only one.\"#,\n            ));\n        }\n\n        // zero or more options: name = \"foo\"\n        let options = input.parse_terminated(syn::MetaNameValue::parse, Token![,])?;\n\n        Ok(Self { path, options })\n    }\n}\n\nmacro_rules! standard_method_type {\n    (\n        $($variant:ident, $upper:ident, $lower:ident,)+\n    ) => {\n        #[doc(hidden)]\n        #[derive(Debug, Clone, PartialEq, Eq, Hash)]","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/actix/actix-web/blob/937960ca67f20e14ffe2a075bf6d4593502be12c/actix-web-codegen/src/route.rs#L27-L63","documentation":"A method macro takes exactly one path. At actix-web-codegen/src/route.rs:44-48, after parsing the first path string and a comma, if the next token is another literal the macro reports a multi-path error rather than silently picking one. Options after the comma must be `key = value` pairs (`name`, `guard`, `wrap`, `method`), not a second path.","triggerScenarios":"`#[get(\"/foo\", \"/bar\")]` — supplying two string literals as if multiple paths were allowed.","commonSituations":"Misunderstanding the macro grammar and assuming a handler can register multiple paths in one attribute.","solutions":["Keep only one path literal as the first argument.","To register the same handler on multiple paths, use `#[routes]` with several method attributes, or register the route multiple times."],"exampleFix":"// before\n#[get(\"/foo\", \"/bar\")]\nasync fn handler() -> HttpResponse { ... }\n\n// after\n#[get(\"/foo\")]\nasync fn handler() -> HttpResponse { ... }\n\n// or multiple paths via routes\n#[routes]\n#[get(\"/foo\")]\n#[get(\"/bar\")]\nasync fn handler() -> HttpResponse { ... }","handlingStrategy":"validation","validationCode":"// Compile-time only. A method macro accepts exactly one string-literal path;\n// subsequent args must be key=value. Review each method attribute to ensure a single path.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use #[routes] with multiple method attributes to map one handler to many paths.","Remember the grammar: #[method(\"/path\", opt=val, ...)]."],"tags":["rust","actix","actix-web","macro","compile-time","routing"],"analyzedSha":"937960ca67f20e14ffe2a075bf6d4593502be12c","analyzedAt":"2026-08-06T01:15:46.978Z","schemaVersion":2}