leptos-rs/leptos · error

keyword argument repeated: `protocol`

Error message

keyword argument repeated: `protocol`

What it means

Same duplicate-key rule as other options: the `impl_deref` keyword may appear at most once in a #[server] attribute. A second occurrence makes the syn parser error at the repeated key's span, since the macro stores it in a single Option.

Source

Thrown at server_fn_macro/src/lib.rs:1181

                    } else if key == "custom" {
                        if custom_wrapper.is_some() {
                            return Err(syn::Error::new(
                                key.span(),
                                "keyword argument repeated: `custom`",
                            ));
                        }
                        custom_wrapper = Some(stream.parse()?);
                    } 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;

View on GitHub (pinned to 32d20f6c9d)

Solutions

  1. Delete the second `impl_deref` entry so the attribute contains exactly one.
  2. Verify the single boolean value matches your intent.
  3. Regenerate the attribute from the documented option list to avoid stray duplicates.

Example fix

// before
#[server(impl_deref = true, impl_deref = true)]
// after
#[server(impl_deref = true)]
Defensive patterns

Strategy: validation

Validate before calling

let attr = "#[server(impl_deref = true, impl_deref = true)]";
assert!(attr.matches("impl_deref").count() <= 1, "duplicate `impl_deref`");

Prevention

When it happens

Trigger: #[server(impl_deref = true, impl_deref = true)]; pasting an existing attribute's options twice; code-generation tools emitting `impl_deref` redundantly.

Common situations: Refactoring where `impl_deref` was appended by an assistant/tool without noticing it already existed; IDE snippets that include the option while the user adds it manually too.

Related errors


AI-assisted analysis of leptos-rs/leptos@32d20f6c9d (2026-09-01). Data as JSON: /api/errors/cf0a9c739be54557. Report an issue: GitHub.