DioxusLabs/dioxus · error · syn::Error

`encoding` and `input` should not both be specified

Error message

`encoding` and `input` should not both be specified

What it means

`encoding` and `input` are mutually exclusive in `#[server(...)]`: `encoding` already defines the input codec. The parser explicitly rejects `input = ...` when `encoding` was set earlier in the same attribute (packages/fullstack-macro/src/lib.rs:1588-1594).

Source

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

                    } 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`",
                            ));
                        }
                        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`",
                            ));
                        }

View on GitHub (pinned to 393d190a80)

Solutions

  1. Remove `encoding` and specify both directions explicitly: `input = Json, output = Json`.
  2. Or remove `input` and keep `encoding` if both directions use the same codec (legacy style).
  3. Standardize the codebase on `input`/`output` to avoid this class of conflict entirely.

Example fix

// before
#[server(encoding = Postcard, input = Json)]
async fn save(data: Data) { ... }

// after
#[server(input = Json, output = Postcard)]
async fn save(data: Data) { ... }
Defensive patterns

Strategy: validation

Validate before calling

# Fail when encoding coexists with input or output in one #[server] attribute
import re, sys
for m in re.finditer(r'#\[server\(([^)]*)\)\]', open('src/server_fns.rs').read(), re.S):
    body = m.group(1)
    if re.search(r'\bencoding\s*=', body) and re.search(r'\b(input|output)\s*=', body):
        sys.exit('encoding must not be combined with input/output: ' + body[:60])

Prevention

When it happens

Trigger: `#[server(encoding = Postcard, input = Json)]`; partial migration from the old `encoding` API to the split `input`/`output` API where `encoding` was left behind; adding `input` while keeping `encoding` 'just in case'.

Common situations: Upgrading Dioxus/server-fn versions where `input`/`output` were introduced alongside legacy `encoding`; tutorials mixing old and new styles.

Related errors


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