leptos-rs/leptos · error
positional argument follows keyword argument
Error message
positional argument follows keyword argument
What it means
The `protocol` keyword is also single-use; a second `protocol = ...` in the #[server] attribute triggers this error at the repeated key's span. The parser treats each known option as set-once to prevent ambiguous overrides.
Source
Thrown at server_fn_macro/src/lib.rs:1189
} else if key == "impl_from" {
if impl_from.is_some() {
return Err(syn::Error::new(
key.span(),
"keyword argument repeated: `impl_from`",
));
}
impl_from = Some(stream.parse()?);
} else if key == "impl_deref" {
if impl_deref.is_some() {
return Err(syn::Error::new(
key.span(),
"keyword argument repeated: `impl_deref`",
));
}
impl_deref = Some(stream.parse()?);
} else if key == "protocol" {
if protocol.is_some() {
return Err(syn::Error::new(
key.span(),
"keyword argument repeated: `protocol`",
));
}
protocol = Some(stream.parse()?);
} else {
return Err(lookahead.error());
}
} else {
let value = key_or_value;
if use_key_and_value {
return Err(syn::Error::new(
value.span(),
"positional argument follows keyword argument",
));
}
if arg_pos == 1 {
struct_name = Some(value)View on GitHub (pinned to 32d20f6c9d)
Solutions
- Keep only one `protocol = ...` argument in the attribute.
- Remove the obsolete protocol value instead of appending the new one next to it.
- Search the attribute for all occurrences of `protocol` before editing.
Example fix
// before #[server(protocol = "grpc", protocol = "grpc-web")] // after #[server(protocol = "grpc-web")]
Defensive patterns
Strategy: validation
Validate before calling
let attr = "#[server(protocol = \"grpc\", protocol = \"grpc-web\")]";
assert!(attr.matches("protocol").count() <= 1, "duplicate `protocol`"); Prevention
- Replace (not append) protocol settings during migration
- Keep protocol config centralized in one macro per function
- Review generated code for repeated keys
When it happens
Trigger: #[server(protocol = "grpc", protocol = "grpc-web")]; combining a protocol line from one attribute with another attribute's options; templated generation that always appends `protocol`.
Common situations: Migrating between protocol settings (e.g. switching protocols) where the old line was commented as code rather than removed; bulk edits across many server functions.
Related errors
- keyword argument repeated: `impl_deref`
- keyword argument repeated: `protocol`
- expected string literal
- If you use keyword arguments (e.g., `name` = Something), the
- unexpected extra argument
AI-assisted analysis of leptos-rs/leptos@32d20f6c9d (2026-09-01).
Data as JSON: /api/errors/b801a9ced64b5620.
Report an issue: GitHub.