DioxusLabs/dioxus · error · syn::Error

keyword argument repeated: `prefix`

Error message

keyword argument repeated: `prefix`

What it means

`prefix` sets the URL prefix for a `#[server]` function's endpoint and may be given at most once. The macro's keyword parser errors on the second `prefix = ...` it encounters (packages/fullstack-macro/src/lib.rs:1564-1570).

Source

Thrown at packages/fullstack-macro/src/lib.rs:1566

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

View on GitHub (pinned to 393d190a80)

Solutions

  1. Keep a single `prefix` entry and spell out the full prefix: `prefix = "/api/v1"`.
  2. If you need per-crate or per-module prefixes, use one `prefix` in the macro and add the rest via your router/mount path.
  3. Check for duplicated attribute lines after resolving git merges.

Example fix

// before
#[server(prefix = "/api", prefix = "/v1")]
async fn get_user() -> User { ... }

// after
#[server(prefix = "/api/v1")]
async fn get_user() -> User { ... }
Defensive patterns

Strategy: validation

Validate before calling

# Reuse the duplicate-key checker from index 93; prefix is in its key list.

Prevention

When it happens

Trigger: `#[server(prefix = "/api", prefix = "/v2")]`; combining `#[server(prefix = "/api")]` with another attribute line that also sets `prefix` after a merge; appending a second prefix while trying to build a nested path.

Common situations: Trying to compose prefixes (`/api` + `/v1`) — the macro does not concatenate them; merge conflicts; copy-paste of a fully-configured attribute onto a function that already had one.

Related errors


AI-assisted analysis of DioxusLabs/dioxus@393d190a80 (2026-08-16). Data as JSON: /api/errors/51e1e058d9a2e001. Report an issue: GitHub.