{"record":{"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":"validation","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/4d435abc281842f3cbee165b6cde739e001d3a25/actix-web-codegen/src/route.rs#L27-L63","documentation":"This compile-time error fires when a route macro receives more than one path string argument. After parsing the first path and the comma separator, the macro checks whether the next token is a literal at line 44; if so, it assumes a second path was intended and rejects it since a route maps to exactly one resource path.","triggerScenarios":"Writing `#[get(\"/users\", \"/admin\")]` or `#[route(\"/api\", \"/v2\")]` with two string literals separated by a comma. The macro interprets the second literal as an erroneous second path.","commonSituations":"Developers who try to register the same handler on multiple paths in a single attribute, or who confuse the `name`, `guard`, and `wrap` options with path arguments.","solutions":["Use only one path string per route attribute","To register multiple paths for the same handler, use separate `#[get(\"/path1\")]` and `#[get(\"/path2\")]` under a `#[routes]` macro","If you intended to pass options, use the key=value syntax: `#[get(\"/users\", name = \"users_list\")]`"],"exampleFix":"// before\n#[get(\"/users\", \"/admin\")]\nasync fn handler() -> impl Responder { ... }\n\n// after\n#[routes]\n#[get(\"/users\")]\n#[get(\"/admin\")]\nasync fn handler() -> impl Responder { ... }","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// Compile-time error. One path per route attribute:\n// #[get(\"/users\")] — correct\n// #[get(\"/users\", \"/admin\")] — incorrect\n// Use #[routes] with multiple method attributes for multi-path handlers.","tryCatchPattern":null,"preventionTips":["Use exactly one string literal path per route attribute","For the same handler on multiple paths, use #[routes] with separate #[get(\"/path1\")] attributes","Review the actix-web codegen documentation for multi-route patterns"],"tags":["rust","actix-web","codegen","routing","compile-time","macro"],"backgroundTag":null,"analyzedSha":"4d435abc281842f3cbee165b6cde739e001d3a25","analyzedAt":"2026-08-09T01:01:40.926Z","contentChangedAt":"2026-08-09T01:01:40.926Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}