DioxusLabs/dioxus · error · syn::Error
keyword argument repeated: `name`
Error message
keyword argument repeated: `name`
What it means
The `#[server(...)]` macro parses its arguments as either positional or `key = value` pairs; the `name` key (custom struct name for the generated client type) may be set at most once. A second `name = ...` is rejected at the macro's parse stage (packages/fullstack-macro/src/lib.rs:1556-1562).
Source
Thrown at packages/fullstack-macro/src/lib.rs:1558
// Check if this looks like an extractor (Ident : Type)
// If so, break out to parse extractors - they must come last
if stream.peek(Ident) && stream.peek2(Token![:]) {
break;
}
arg_pos += 1;
let lookahead = stream.lookahead1();
if lookahead.peek(Ident) {
let key_or_value: Ident = stream.parse()?;
let lookahead = stream.lookahead1();
if lookahead.peek(Token![=]) {
stream.parse::<Token![=]>()?;
let key = key_or_value;
use_key_and_value = true;
if key == "name" {
if struct_name.is_some() {
return Err(syn::Error::new(
key.span(),
"keyword argument repeated: `name`",
));
}
struct_name = Some(stream.parse()?);
} 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`",View on GitHub (pinned to 393d190a80)
Solutions
- Delete one of the `name = ...` entries so exactly one remains.
- If two names are genuinely needed, they belong on two separate `#[server]` functions.
- After merge conflicts, grep the attribute body for duplicated keys before building.
Example fix
// before
#[server(name = FetchA, name = FetchB, endpoint = "https://api.example.com")]
async fn fetch() -> i32 { ... }
// after
#[server(name = FetchA, endpoint = "https://api.example.com")]
async fn fetch() -> i32 { ... } Defensive patterns
Strategy: validation
Validate before calling
#!/usr/bin/env python3
# Fail on any repeated key inside a single #[server(...)] attribute.
import re, sys, collections
for m in re.finditer(r'#\[server\(([^)]*)\)\]', open('src/server_fns.rs').read(), re.S):
keys = re.findall(r'\b(name|prefix|encoding|endpoint|input|input_derive|output|output_derive|server|client|custom|impl_from|impl_deref|protocol)\s*=', m.group(1))
dupes = [k for k, n in collections.Counter(keys).items() if n > 1]
if dupes:
sys.exit(f'duplicate #[server] keys: {dupes} in {m.group(1)[:60]!r}') Prevention
- After merge conflicts or scaffolding, grep #[server] bodies for repeated `key =` before building.
- Generate attributes from one template/snippet rather than stacking edits.
When it happens
Trigger: `#[server(name = FetchA, name = FetchB)]`; merging two attribute blocks during refactor so `name` appears twice; switching from positional to keyword style and forgetting to delete the first occurrence.
Common situations: Copy-pasting server functions and editing attributes incrementally; merge conflicts resolved by keeping both `name =` lines; bulk renames that append rather than replace.
Related errors
- keyword argument repeated: `prefix`
- keyword argument repeated: `encoding`
- keyword argument repeated: `endpoint`
- `encoding` and `input` should not both be specified
- keyword argument repeated: `input`
AI-assisted analysis of DioxusLabs/dioxus@393d190a80 (2026-08-16).
Data as JSON: /api/errors/9695c661b4940401.
Report an issue: GitHub.