DioxusLabs/dioxus · error · syn::Error
Expected middleware attribute to be a list, e.g…
Error message
Expected middleware attribute to be a list, e.g. #[middleware(MyLayer::new())]
What it means
Error in route_impl_with_route's middleware collection: a #[middleware] attribute on a #[server] function was not Meta::List. The middleware attribute must carry a layer expression as a list, e.g. #[middleware(MyLayer::new())]; the faulting input is the malformed attribute form.
Solutions
- Write the middleware attribute as a list, e.g. #[middleware(MyLayer::new())], instead of a bare path or value.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/fullstack-macro/src/lib.rs:216 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of DioxusLabs/dioxus@24f6a829df (2026-08-23).
Data as JSON: /api/errors/897be4a28f470bdd.
Report an issue: GitHub.
Appendix: source
Thrown at packages/fullstack-macro/src/lib.rs:216
fn route_impl_with_route(
route: Route,
item: TokenStream,
method_from_macro: Option<Method>,
) -> syn::Result<TokenStream2> {
// Parse the route and function
let mut function = syn::parse::<ItemFn>(item)?;
// Collect the middleware initializers
let middleware_layers = function
.attrs
.iter()
.filter(|attr| attr.path().is_ident("middleware"))
.map(|f| match &f.meta {
Meta::List(meta_list) => Ok({
let tokens = &meta_list.tokens;
quote! { .layer(#tokens) }
}),
_ => Err(Error::new(
f.span(),
"Expected middleware attribute to be a list, e.g. #[middleware(MyLayer::new())]",
)),
})
.collect::<Result<Vec<_>>>()?;
// don't re-emit the middleware attribute on the inner
function
.attrs
.retain(|attr| !attr.path().is_ident("middleware"));
// Attach `#[allow(unused_mut)]` to all original inputs to avoid warnings
let outer_inputs = function
.sig
.inputs
.iter()
.enumerate()
.map(|(i, arg)| match arg {View on GitHub (pinned to 24f6a829df)