DioxusLabs/dioxus · error · syn::Error

path parameter `{}` not found in function arguments

Error message

path parameter `{}` not found in function arguments

What it means

Thrown while compiling a dioxus-fullstack route: a `{name}` capture segment appears in the route string, but no function argument with that exact identifier exists. The macro binds each `{param}` path segment to a same-named function argument (removing it from the body/extractor arguments), so a missing argument cannot be compiled.

Source

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

        let mut arg_map = sig
            .inputs
            .iter()
            .enumerate()
            .filter_map(|(i, item)| match item {
                syn::FnArg::Receiver(_) => None,
                syn::FnArg::Typed(pat_type) => Some((i, pat_type)),
            })
            .filter_map(|(i, pat_type)| match &*pat_type.pat {
                syn::Pat::Ident(ident) => Some((ident.ident.clone(), (pat_type.ty.clone(), i))),
                _ => None,
            })
            .collect::<HashMap<_, _>>();

        for (_slash, path_param) in &mut route.path_params {
            match path_param {
                PathParam::Capture(_lit, _, 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::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) => {}

View on GitHub (pinned to 393d190a80)

Solutions

  1. Add a function argument with exactly the same name as the `{param}` in the route string and a type implementing `FromStr`/`Deserialize` (e.g. `id: i32`).
  2. If the argument was renamed, change the route string to match the new identifier: `/blog/{post_id}` with `post_id: i32`.
  3. If the segment should not be captured, make it static text in the route string (remove the curly braces).

Example fix

// before
#[route(GET, "/blog/{id}")]
async fn blog() -> String { ... }

// after
#[route(GET, "/blog/{id}")]
async fn blog(id: i32) -> String { ... }
Defensive patterns

Strategy: validation

Validate before calling

#!/usr/bin/env python3
# Fail when a {param}/*param/?param in a route string has no matching fn argument.
import re, sys
src = open('src/routes.rs').read()
for m in re.finditer(r'#\[(?:api_)?route\([^\"]*"([^"]+)"[^)]*\)\]\s*(?:pub )?(?:async )?fn (\w+)\(([^)]*)\)', src):
    route, _fname, args = m.group(1), m.group(2), m.group(3)
    idents = set(re.findall(r'(\w+)\s*:', args))
    need = set(re.findall(r'\{(\w+)\}', route.split('?')[0]))
    missing = need - idents
    if missing:
        sys.exit(f'route "{route}": path params not in fn args: {missing}')

Prevention

When it happens

Trigger: `#[route(GET, "/blog/{id}")]` on a function whose signature lacks `id: i32`; a renamed Rust argument (e.g. `post_id`) while the route still says `{id}`; a typo or different casing between route string (`{userId}`) and argument (`user_id`), since matching is exact identifier equality.

Common situations: Renaming function parameters during refactoring without updating the route string; copying a handler from another route with different param names; using snake_case/camelCase inconsistently between URL design and Rust identifiers.

Related errors


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