leptos-rs/leptos · error
Unrecognized #[server] attribute, expected #[server(default)
Error message
Unrecognized #[server] attribute, expected #[server(default)] or #[server(rename = "fieldName")]
What it means
On struct fields of a server-function argument struct, the macro only recognizes #[server(default)] and #[server(rename = "fieldName")] (and paths for the latter form). Any other #[server(...)] meta on a field is rejected with this message naming the two allowed forms.
Source
Thrown at server_fn_macro/src/lib.rs:1405
Ok(attr.clone())
}
// #[server(default = "value")]
Meta::NameValue(name_value)
if name_value.path.is_ident("default") =>
{
Ok(attr.clone())
}
// #[server(skip)]
Meta::Path(path) if path.is_ident("skip") => {
Ok(attr.clone())
}
// #[server(rename = "value")]
Meta::NameValue(name_value)
if name_value.path.is_ident("rename") =>
{
Ok(attr.clone())
}
_ => Err(Error::new(
attr.span(),
"Unrecognized #[server] attribute, expected \
#[server(default)] or #[server(rename = \
\"fieldName\")]",
)),
}
} else if attr.path().is_ident("doc") {
// Allow #[doc = "documentation"]
Ok(attr.clone())
} else if attr.path().is_ident("allow") {
// Allow #[allow(...)]
Ok(attr.clone())
} else if attr.path().is_ident("deny") {
// Allow #[deny(...)]
Ok(attr.clone())
} else if attr.path().is_ident("ignore") {
// Allow #[ignore]
Ok(attr.clone())View on GitHub (pinned to 32d20f6c9d)
Solutions
- Restrict field attributes to #[server(default)] or #[server(rename = "fieldName").
- For other serde behavior, use the actual serde attributes handled by your input derive instead of #[server(...)].
- Fix typos in `rename` and supply the required "value".
Example fix
// before #[server(skip)] field: String, // after #[serde(skip)] #[server] field: String,
Defensive patterns
Strategy: validation
Validate before calling
let allowed = ["default", "rename"];
let attr_meta = "skip"; // contents of #[server(...)] on a field
assert!(allowed.contains(&attr_meta) || attr_meta.starts_with("rename "), "field attr must be #[server(default)] or #[server(rename = \"x\")]" ); Prevention
- Use serde attributes for serde-only behaviors
- Keep field attribute usage to the two documented forms
- Check docs after upgrading server_fn for new field options
When it happens
Trigger: #[server(skip)] or #[server(flatten)] on a field; #[server(rename)] without a value; copying serde-style attributes onto fields where only default/rename are supported.
Common situations: Developers assuming full serde attribute parity; migrating from another derive that supported more field options; typo like `renamed = "x"`.
Related errors
- Unrecognized attribute, expected #[server(...)]
- keyword argument repeated: `encoding`
- keyword argument repeated: `endpoint`
- `encoding` and `input` should not both be specified
- keyword argument repeated: `input`
AI-assisted analysis of leptos-rs/leptos@32d20f6c9d (2026-09-01).
Data as JSON: /api/errors/524be76320266830.
Report an issue: GitHub.