DioxusLabs/dioxus · error · syn::Error
keyword argument repeated: `encoding`
Error message
keyword argument repeated: `encoding`
What it means
`encoding` is the legacy shortcut in `#[server(...)]` that sets both input and output codecs (e.g. `encoding = postcard`). It may be specified only once; the parser rejects a second `encoding = ...` (packages/fullstack-macro/src/lib.rs:1572-1578).
Source
Thrown at packages/fullstack-macro/src/lib.rs:1574
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`",
));
}
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 \View on GitHub (pinned to 393d190a80)
Solutions
- Delete the duplicate so one `encoding = ...` remains.
- For mixed codecs, drop `encoding` entirely and use `input = Json, output = Postcard` (one each).
- Prefer the explicit `input`/`output` form in new code; it composes and errors like this one disappear.
Example fix
// before
#[server(encoding = Json, encoding = Postcard)]
async fn ping() -> i32 { ... }
// after
#[server(input = Json, output = Postcard)]
async fn ping() -> i32 { ... } Defensive patterns
Strategy: validation
Validate before calling
# Reuse the duplicate-key checker from index 93; encoding is in its key list.
Prevention
- New code: use input=/output=, never encoding=, so per-direction intent is explicit.
- Sweep the repo for `encoding =` when upgrading Dioxus versions and migrate all at once.
When it happens
Trigger: `#[server(encoding = Json, encoding = Postcard)]`; adding `encoding` when migrating an old attribute that already had one; trying to use different codecs for request vs response via two `encoding` keys.
Common situations: Upgrading old server functions that used `encoding` while also adding a new one; misunderstanding that per-direction configuration uses `input = ...` / `output = ...`, not repeated `encoding`.
Related errors
- `encoding` and `input` should not both be specified
- keyword argument repeated: `input`
- keyword argument repeated: `name`
- keyword argument repeated: `prefix`
- keyword argument repeated: `endpoint`
AI-assisted analysis of DioxusLabs/dioxus@393d190a80 (2026-08-16).
Data as JSON: /api/errors/079a3530810f7689.
Report an issue: GitHub.