{"record":{"id":"c3816db7ca129dee","repo":"leptos-rs/leptos","slug":"expected-string-literal","errorCode":null,"errorMessage":"expected string literal","messagePattern":"expected string literal","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server_fn_macro/src/lib.rs","lineNumber":1201,"sourceCode":"                                \"keyword argument repeated: `impl_deref`\",\n                            ));\n                        }\n                        impl_deref = Some(stream.parse()?);\n                    } else if key == \"protocol\" {\n                        if protocol.is_some() {\n                            return Err(syn::Error::new(\n                                key.span(),\n                                \"keyword argument repeated: `protocol`\",\n                            ));\n                        }\n                        protocol = Some(stream.parse()?);\n                    } else {\n                        return Err(lookahead.error());\n                    }\n                } else {\n                    let value = key_or_value;\n                    if use_key_and_value {\n                        return Err(syn::Error::new(\n                            value.span(),\n                            \"positional argument follows keyword argument\",\n                        ));\n                    }\n                    if arg_pos == 1 {\n                        struct_name = Some(value)\n                    } else {\n                        return Err(syn::Error::new(\n                            value.span(),\n                            \"expected string literal\",\n                        ));\n                    }\n                }\n            } else if lookahead.peek(LitStr) {\n                if use_key_and_value {\n                    return Err(syn::Error::new(\n                        stream.span(),\n                        \"If you use keyword arguments (e.g., `name` = \\","sourceCodeStart":1183,"sourceCodeEnd":1219,"githubUrl":"https://github.com/leptos-rs/leptos/blob/32d20f6c9d517451d77beb68d88c7716823dac41/server_fn_macro/src/lib.rs#L1183-L1219","documentation":"In the #[server] macro's argument list, only the FIRST positional argument is allowed (the struct name, and it must be an Ident). If a second bare (non-keyword) identifier argument appears, the parser rejects it with 'expected string literal' because positional slot 2+ only accepts string literals (prefix, encoding, endpoint).","triggerScenarios":"#[server(MyServerFn, SomeExtraIdent)] — a second bare ident after the function/struct name; forgetting the `= value` after an intended keyword so it is parsed as a positional ident; typos like #[server(MyFn, UrlEnc)] instead of encoding = \"UrlEnc\".","commonSituations":"Users migrating between the legacy positional form (name, \"prefix\", \"encoding\", \"endpoint\") and keyword form, mixing bare idents where strings were required.","solutions":["Remove the extra bare identifier — only one positional argument is allowed.","If you meant an option, give it its keyword: e.g. encoding = \"Url\".","If you meant a string option, pass a string literal such as \"api/prefix\" instead of an ident."],"exampleFix":"// before\n#[server(MyServerFn, UrlEnc)]\n// after\n#[server(MyServerFn, encoding = \"UrlEnc\")]","handlingStrategy":"validation","validationCode":"// Only the first bare Ident is legal; any other option needs `key = value`.\nfn is_positional_ok(args: &[&str]) -> bool {\n    args.iter().skip(1).all(|a| a.contains('='))\n}\nassert!(is_positional_ok(&[\"MyFn\", \"UrlEnc\"])); // fails before compiling","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer keyword arguments for everything except the struct name","Quote string options: encoding = \"Url\", prefix = \"api\"","Run cargo check after each attribute edit"],"tags":["rust","proc-macro","parse-error","positional-argument"],"backgroundTag":"macro-argument-parse-error","analyzedSha":"32d20f6c9d517451d77beb68d88c7716823dac41","analyzedAt":"2026-09-01T18:55:42.580Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T01:17:15.007Z"}