leptos-rs/leptos · error
keyword argument repeated: `input`
Error message
keyword argument repeated: `input`
What it means
This error is raised when the `input` keyword argument appears more than once in a #[server] attribute. Because `input` names the custom request-body type, a second value would be contradictory, so the parser rejects the duplicate at compile time with a span on the repeated key.
Source
Thrown at server_fn_macro/src/lib.rs:1119
}
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`",
));
}
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 \View on GitHub (pinned to 32d20f6c9d)
Solutions
- Keep only one `input = ...` entry and delete the other.
- If different input types are needed for variants, define separate server functions.
- Fix macro wrappers to append `input` only when not already present.
Example fix
// before
#[server(input = MyInput, input = OtherInput)]
async fn save(data: MyInput) -> Result<(), ServerFnError> { todo!() }
// after
#[server(input = MyInput)]
async fn save(data: MyInput) -> Result<(), ServerFnError> { todo!() } Defensive patterns
Strategy: validation
Validate before calling
// Pre-commit check for duplicate `input` args: // grep -rnE '#\[server\([^)\n]*input\s*=[^)\n]*input\s*=' src/ && exit 1 || exit 0
Prevention
- One `input = ...` per attribute; rename, don't append.
- When changing input types, replace the old line rather than adding a new one.
- Audit macro_rules! wrappers that inject `input` for collision with user args.
- Compile in CI so macro parse errors are caught before merge.
When it happens
Trigger: Writing #[server(input = A, input = B)] in the same attribute, or a macro_rules! wrapper injecting `input` while the user already supplied one.
Common situations: Copy-paste of attribute args between functions, refactoring where a type was renamed and both old and new `input` lines remained, or generated macro layers that each add input.
Related errors
- keyword argument repeated: `encoding`
- keyword argument repeated: `endpoint`
- `encoding` and `input` should not both be specified
- `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/99639cc0bd103a3c.
Report an issue: GitHub.