leptos-rs/leptos · error
keyword argument repeated: `endpoint`
Error message
keyword argument repeated: `endpoint`
What it means
The #[server] macro parser throws this when the `endpoint` keyword argument is specified more than once. `endpoint` sets the custom function path (fn_path); a second occurrence is ambiguous, so compilation fails with a span pointing at the repeated key.
Source
Thrown at server_fn_macro/src/lib.rs:1105
} else if key == "prefix" {
if prefix.is_some() {
return Err(syn::Error::new(
key.span(),
"keyword argument repeated: `prefix`",
));
}
prefix = Some(stream.parse()?);
} else if key == "encoding" {
if encoding.is_some() {
return Err(syn::Error::new(
key.span(),
"keyword argument repeated: `encoding`",
));
}
encoding = Some(stream.parse()?);
} else if key == "endpoint" {
if fn_path.is_some() {
return Err(syn::Error::new(
key.span(),
"keyword argument repeated: `endpoint`",
));
}
fn_path = Some(stream.parse()?);
} else if key == "input" {
if encoding.is_some() {
return Err(syn::Error::new(
key.span(),
"`encoding` and `input` should not both be \
specified",
));
} else if input.is_some() {
return Err(syn::Error::new(
key.span(),
"keyword argument repeated: `input`",
));
}View on GitHub (pinned to 32d20f6c9d)
Solutions
- Delete the extra `endpoint = ...` entry, keeping only the desired path.
- If different endpoints are needed, declare separate #[server] functions instead.
- Audit any macro wrapper so it only adds endpoint when absent.
Example fix
// before
#[server(endpoint = "/api/save", endpoint = "/api/save-v2")]
async fn save(data: String) -> Result<(), ServerFnError> { todo!() }
// after
#[server(endpoint = "/api/save-v2")]
async fn save(data: String) -> Result<(), ServerFnError> { todo!() } Defensive patterns
Strategy: validation
Validate before calling
// Pre-commit check for duplicate `endpoint` args in #[server]: // grep -rnE '#\[server\([^)\n]*endpoint\s*=[^)\n]*endpoint\s*=' src/ && exit 1 || exit 0
Prevention
- Declare only one endpoint path per server function.
- Need different paths? Create separate #[server] functions rather than stacking endpoint args.
- Keep endpoint paths centralized (constants) to avoid hand-editing duplicates.
- Run cargo check/clippy in CI to catch macro parse errors early.
When it happens
Trigger: Writing #[server(...)] with two `endpoint = "..."` entries, e.g. #[server(endpoint = "/a", endpoint = "/b")], or a macro wrapper that injects endpoint while the user also wrote one.
Common situations: Copy-paste of attribute args, merging two annotations during refactoring, or macro_rules! layers that each add an endpoint.
Related errors
- keyword argument repeated: `encoding`
- `encoding` and `input` should not both be specified
- keyword argument repeated: `input`
- `encoding` and `output` should not both be specified
- keyword argument repeated: `output`
AI-assisted analysis of leptos-rs/leptos@32d20f6c9d (2026-09-01).
Data as JSON: /api/errors/7f9524f29c22a198.
Report an issue: GitHub.