leptos-rs/leptos · error
keyword argument repeated: `output`
Error message
keyword argument repeated: `output`
What it means
This error is thrown when the `output` keyword argument is repeated in a #[server] attribute. `output` designates the custom response type; a second occurrence is ambiguous, so the parser rejects it at compile time with a span on the duplicate key.
Source
Thrown at server_fn_macro/src/lib.rs:1135
));
} else if input.is_some() {
return Err(syn::Error::new(
key.span(),
"keyword argument repeated: `input`",
));
}
input = Some(stream.parse()?);
} else if key == "input_derive" {
if input_derive.is_some() {
return Err(syn::Error::new(
key.span(),
"keyword argument repeated: `input_derive`",
));
}
input_derive = Some(stream.parse()?);
} else if key == "output" {
if encoding.is_some() {
return Err(syn::Error::new(
key.span(),
"`encoding` and `output` should not both be \
specified",
));
} else if output.is_some() {
return Err(syn::Error::new(
key.span(),
"keyword argument repeated: `output`",
));
}
output = Some(stream.parse()?);
} else if key == "server" {
if server.is_some() {
return Err(syn::Error::new(
key.span(),
"keyword argument repeated: `server`",
));
}View on GitHub (pinned to 32d20f6c9d)
Solutions
- Keep a single `output = ...` entry and delete the rest.
- Use separate server functions if different output types are required.
- Make macro wrappers conditionally emit `output` only when absent.
Example fix
// before
#[server(output = Json<MyOutput>, output = MyOutput)]
async fn load() -> Result<MyOutput, ServerFnError> { todo!() }
// after
#[server(output = MyOutput)]
async fn load() -> Result<MyOutput, ServerFnError> { todo!() } Defensive patterns
Strategy: validation
Validate before calling
// Pre-commit check for duplicate `output` args: // grep -rnE '#\[server\([^)\n]*output\s*=[^)\n]*output\s*=' src/ && exit 1 || exit 0
Prevention
- Declare `output` at most once per attribute.
- When changing output types, edit the existing entry instead of adding a new one.
- Review macro wrappers that append `output` automatically.
- Rely on cargo check in CI to surface duplicate-key errors.
When it happens
Trigger: Writing #[server(output = A, output = B)] in one attribute, or a macro_rules! wrapper that injects `output` while the user already specified one.
Common situations: Copy-paste of attribute lines, renaming an output type and leaving both entries, generated macro layers each adding output.
Related errors
- keyword argument repeated: `encoding`
- keyword argument repeated: `endpoint`
- `encoding` and `input` should not both be specified
- keyword argument repeated: `input`
- `encoding` and `output` should not both be specified
AI-assisted analysis of leptos-rs/leptos@32d20f6c9d (2026-09-01).
Data as JSON: /api/errors/0c385c843c9653a4.
Report an issue: GitHub.