DioxusLabs/dioxus · error · syn::Error

query parameter `{}` not found in function arguments

Error message

query parameter `{}` not found in function arguments

What it means

Thrown when the query string part of a dioxus-fullstack route (after `?`) declares a parameter that has no matching function argument. Each `?a=1&b` query segment binds to a same-named function argument (`name=binding` syntax lets the URL name differ from the Rust identifier); a missing argument is a compile error.

Source

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

                }
                PathParam::WildCard(_lit, _, _star, ident, ty, _) => {
                    let (new_ident, new_ty) = arg_map.remove_entry(ident).ok_or_else(|| {
                        syn::Error::new(
                            ident.span(),
                            format!("path parameter `{}` not found in function arguments", ident),
                        )
                    })?;
                    *ident = new_ident;
                    *ty = new_ty.0;
                }
                PathParam::Static(_lit) => {}
            }
        }

        let mut query_params = Vec::new();
        for param in route.query_params {
            let (ident, ty) = arg_map.remove_entry(&param.binding).ok_or_else(|| {
                syn::Error::new(
                    param.binding.span(),
                    format!(
                        "query parameter `{}` not found in function arguments",
                        param.binding
                    ),
                )
            })?;
            query_params.push(QueryParam {
                binding: ident,
                name: param.name,
                catch_all: param.catch_all,
                ty: ty.0,
                arg_idx: ty.1,
            });
        }

        // Disallow multiple query params if one is a catch-all
        if query_params.iter().any(|param| param.catch_all) && query_params.len() > 1 {

View on GitHub (pinned to 393d190a80)

Solutions

  1. Add a function argument named exactly like the query parameter (e.g. `q: String`) — it should impl `Deserialize` (or `FromStr`) since it arrives from the query string.
  2. If URL and Rust names must differ, use the `url_name=rust_binding` syntax in the route string: `/search?search=q` binds URL key `search` to argument `q`.
  3. Remove the extra query segment from the route string if it should not be accepted.

Example fix

// before
#[route(GET, "/search?q")]
async fn search() -> Vec<Item> { ... }

// after
#[route(GET, "/search?q")]
async fn search(q: String) -> Vec<Item> { ... }
Defensive patterns

Strategy: validation

Validate before calling

# Extend the route checker to query params (bare, name=binding, and catch-all forms):
# if '?' in route:
#     q = route.split('?', 1)[1]
#     need |= {b if (p := seg.split('=')) and (b := p[1] if '=' in seg else seg) and not seg.startswith((':', '{')) else None for seg in q.split('&')} - {None}

Prevention

When it happens

Trigger: `#[route(GET, "/search?q")]` on a function with no `q` argument; using `?sort=order` (URL name `sort`, binding `order`) when the function argument is named `sort` instead of `order`; adding a query param to the route string during development without updating the signature.

Common situations: Iterating on filter/search endpoints and adding URL params faster than handler signatures; misunderstanding the `name=binding` split; renaming Rust arguments without syncing the route string.

Related errors


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