{"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":"exception","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/937960ca67f20e14ffe2a075bf6d4593502be12c/actix-web-codegen/src/scope.rs#L1-L37","documentation":"The `#[scope(...)]` macro requires a prefix argument. At actix-web-codegen/src/scope.rs:18-23, if the args token stream is empty the macro errors with the expected form `#[scope(\"/prefix\")]`.","triggerScenarios":"Writing `#[scope]` with no parentheses, or `#[scope()]` with empty parens.","commonSituations":"Treating `scope` like a marker attribute that needs no args, or a typo deleting the prefix string.","solutions":["Provide a prefix string literal: `#[scope(\"/api\")]`.","If you want no prefix, use an empty string `#[scope(\"\")]` (but a non-empty prefix is the normal use)."],"exampleFix":"// before\n#[scope]\nmod api { ... }\n\n// after\n#[scope(\"/api\")]\nmod api { ... }","handlingStrategy":"validation","validationCode":"// Compile-time only. #[scope] requires a non-empty argument.\n// Always write #[scope(\"/prefix\")] with a string literal prefix.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never use bare #[scope]; always pass a prefix.","Use the runtime web::scope(\"/prefix\") builder if you prefer runtime construction."],"tags":["rust","actix","actix-web","macro","compile-time","routing"],"analyzedSha":"937960ca67f20e14ffe2a075bf6d4593502be12c","analyzedAt":"2026-08-06T01:15:46.978Z","schemaVersion":2}