{"record":{"id":"8acd43ec6ca73595","repo":"DioxusLabs/dioxus","slug":"path-parameter-not-found-in-function-argument","errorCode":null,"errorMessage":"path parameter `{}` not found in function arguments","messagePattern":"path parameter `(.+?)` not found in function arguments","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"packages/fullstack-macro/src/lib.rs","lineNumber":673,"sourceCode":"        let mut arg_map = sig\n            .inputs\n            .iter()\n            .enumerate()\n            .filter_map(|(i, item)| match item {\n                syn::FnArg::Receiver(_) => None,\n                syn::FnArg::Typed(pat_type) => Some((i, pat_type)),\n            })\n            .filter_map(|(i, pat_type)| match &*pat_type.pat {\n                syn::Pat::Ident(ident) => Some((ident.ident.clone(), (pat_type.ty.clone(), i))),\n                _ => None,\n            })\n            .collect::<HashMap<_, _>>();\n\n        for (_slash, path_param) in &mut route.path_params {\n            match path_param {\n                PathParam::Capture(_lit, _, ident, ty, _) => {\n                    let (new_ident, new_ty) = arg_map.remove_entry(ident).ok_or_else(|| {\n                        syn::Error::new(\n                            ident.span(),\n                            format!(\"path parameter `{}` not found in function arguments\", ident),\n                        )\n                    })?;\n                    *ident = new_ident;\n                    *ty = new_ty.0;\n                }\n                PathParam::WildCard(_lit, _, _star, ident, ty, _) => {\n                    let (new_ident, new_ty) = arg_map.remove_entry(ident).ok_or_else(|| {\n                        syn::Error::new(\n                            ident.span(),\n                            format!(\"path parameter `{}` not found in function arguments\", ident),\n                        )\n                    })?;\n                    *ident = new_ident;\n                    *ty = new_ty.0;\n                }\n                PathParam::Static(_lit) => {}","sourceCodeStart":655,"sourceCodeEnd":691,"githubUrl":"https://github.com/DioxusLabs/dioxus/blob/393d190a801ccb441d41923e232289b4f8a5c669/packages/fullstack-macro/src/lib.rs#L655-L691","documentation":"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.","triggerScenarios":"`#[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.","commonSituations":"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.","solutions":["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`).","If the argument was renamed, change the route string to match the new identifier: `/blog/{post_id}` with `post_id: i32`.","If the segment should not be captured, make it static text in the route string (remove the curly braces)."],"exampleFix":"// before\n#[route(GET, \"/blog/{id}\")]\nasync fn blog() -> String { ... }\n\n// after\n#[route(GET, \"/blog/{id}\")]\nasync fn blog(id: i32) -> String { ... }","handlingStrategy":"validation","validationCode":"#!/usr/bin/env python3\n# Fail when a {param}/*param/?param in a route string has no matching fn argument.\nimport re, sys\nsrc = open('src/routes.rs').read()\nfor m in re.finditer(r'#\\[(?:api_)?route\\([^\\\"]*\"([^\"]+)\"[^)]*\\)\\]\\s*(?:pub )?(?:async )?fn (\\w+)\\(([^)]*)\\)', src):\n    route, _fname, args = m.group(1), m.group(2), m.group(3)\n    idents = set(re.findall(r'(\\w+)\\s*:', args))\n    need = set(re.findall(r'\\{(\\w+)\\}', route.split('?')[0]))\n    missing = need - idents\n    if missing:\n        sys.exit(f'route \"{route}\": path params not in fn args: {missing}')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Write the route string and the signature together: every {name} you type must immediately become an argument.","Run `cargo check` after every route-string edit — this class of error is caught instantly and cheaply.","Prefer renaming via IDE so route string and argument are changed in one reviewable diff."],"tags":["dioxus","proc-macro","routes","path-params","compile-time"],"backgroundTag":null,"analyzedSha":"393d190a801ccb441d41923e232289b4f8a5c669","analyzedAt":"2026-08-16T11:27:45.815Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}