{"record":{"id":"27b2520309689958","repo":"actix/actix-web","slug":"missing-arguments-for-scope-macro-expected-sco","errorCode":null,"errorMessage":"missing arguments for scope macro, expected: #[scope(\"/prefix\")]","messagePattern":"missing arguments for scope macro, expected: #\\[scope\\(\"/prefix\"\\)\\]","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"actix-web-codegen/src/scope.rs","lineNumber":19,"sourceCode":"use proc_macro::TokenStream;\nuse proc_macro2::{Span, TokenStream as TokenStream2};\nuse quote::{quote, ToTokens as _};\n\nuse crate::{\n    input_and_compile_error,\n    route::{MethodType, RouteArgs},\n};\n\npub fn with_scope(args: TokenStream, input: TokenStream) -> TokenStream {\n    match with_scope_inner(args, input.clone()) {\n        Ok(stream) => stream,\n        Err(err) => input_and_compile_error(input, err),\n    }\n}\n\nfn with_scope_inner(args: TokenStream, input: TokenStream) -> syn::Result<TokenStream> {\n    if args.is_empty() {\n        return Err(syn::Error::new(\n            Span::call_site(),\n            \"missing arguments for scope macro, expected: #[scope(\\\"/prefix\\\")]\",\n        ));\n    }\n\n    let scope_prefix = syn::parse::<syn::LitStr>(args.clone()).map_err(|err| {\n        syn::Error::new(\n            err.span(),\n            \"argument to scope macro is not a string literal, expected: #[scope(\\\"/prefix\\\")]\",\n        )\n    })?;\n\n    let scope_prefix_value = scope_prefix.value();\n\n    if scope_prefix_value.ends_with('/') {\n        // trailing slashes cause non-obvious problems\n        // it's better to point them out to developers rather than\n","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/actix/actix-web/blob/4d435abc281842f3cbee165b6cde739e001d3a25/actix-web-codegen/src/scope.rs#L1-L37","documentation":"This compile-time error fires when the `#[scope(\"...\")]` macro is used without any arguments at all (i.e., `#[scope]` with empty parentheses or no parentheses). The macro checks `args.is_empty()` at line 18 and requires a string literal prefix argument.","triggerScenarios":"Writing `#[scope]` or `#[scope()]` on a module. The macro expects the form `#[scope(\"/prefix\")]` with a non-empty string literal argument.","commonSituations":"Developers who add `#[scope]` without reading the docs, or who delete the path argument during editing and forget to restore it.","solutions":["Provide a string literal path prefix: `#[scope(\"/api\")]`","If you don't need a path prefix, consider whether the scope macro is needed at all","Ensure the argument is inside the parentheses: `#[scope(\"/api\")]` not `#[scope] \"/api\"`"],"exampleFix":"// before\n#[scope]\nmod api { ... }\n\n// after\n#[scope(\"/api\")]\nmod api { ... }","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// Compile-time error. Always provide a string literal argument:\n// #[scope(\"/api\")] — correct\n// #[scope] — incorrect (missing argument)\n// #[scope()] — incorrect (empty argument)","tryCatchPattern":null,"preventionTips":["Always include a string literal path prefix in #[scope(\"/prefix\")]","Follow the actix-web scope macro examples from the documentation","Run cargo check after adding #[scope] to catch missing arguments"],"tags":["rust","actix-web","codegen","routing","compile-time","macro","scope"],"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"}