{"record":{"id":"17c6f51600bb637a","repo":"tokio-rs/axum","slug":"missing-path-typed-path-foo-bar","errorCode":null,"errorMessage":"Missing path: #[typed_path(\"/foo/bar\")]","messagePattern":"Missing path: #\\[typed_path\\(\"/foo/bar\"\\)\\]","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"axum-macros/src/typed_path.rs","lineNumber":26,"sourceCode":"    let ItemStruct {\n        attrs,\n        ident,\n        generics,\n        fields,\n        ..\n    } = item_struct;\n\n    if !generics.params.is_empty() || generics.where_clause.is_some() {\n        return Err(syn::Error::new_spanned(\n            generics,\n            \"`#[derive(TypedPath)]` doesn't support generics\",\n        ));\n    }\n\n    let Attrs { path, rejection } = crate::attr_parsing::parse_attrs(\"typed_path\", attrs)?;\n\n    let path = path.ok_or_else(|| {\n        syn::Error::new(\n            Span::call_site(),\n            \"Missing path: `#[typed_path(\\\"/foo/bar\\\")]`\",\n        )\n    })?;\n\n    let rejection = rejection.map(second);\n\n    match fields {\n        syn::Fields::Named(_) => {\n            let segments = parse_path(&path)?;\n            Ok(expand_named_fields(\n                ident,\n                &path,\n                &segments,\n                rejection.as_ref(),\n            ))\n        }\n        syn::Fields::Unnamed(fields) => {","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/tokio-rs/axum/blob/151cd5c12325373b86daf405a6afc0a0086a6706/axum-macros/src/typed_path.rs#L8-L44","documentation":"Thrown by #[derive(TypedPath)] (typed_path.rs:26). The derive parses attributes named typed_path via parse_attrs; the Attrs::parse parser only fills the path field when it peeks a LitStr. If after parsing, path is None (no #[typed_path(\"...\")] attribute present, or only a rejection(...) sub-attribute was given with no string literal), path.ok_or_else emits this error. (Generics, or a non-struct item, produce different errors upstream.)","triggerScenarios":"#[derive(TypedPath)] struct MyPath { ... } with no #[typed_path(\"...\")] attribute. Also triggered by #[typed_path(rejection(Foo))] without a path string, since the rejection keyword does not set path.","commonSituations":"Forgetting the typed_path attribute entirely. Misspelling it (e.g. #[path(\"...\")]). Adding #[derive(TypedPath)] alongside other derives and assuming the route comes from elsewhere (e.g. from an axum::Router::route call). Only supplying a rejection type and omitting the route literal.","solutions":["Add the attribute with a route literal: #[typed_path(\"/your/route\")].","Make sure the route starts with '/' (a missing leading slash raises a separate error).","If you only want a rejection override, still include the path: #[typed_path(\"/foo\", rejection(MyRejection))]."],"exampleFix":"// before\n#[derive(TypedPath, Deserialize)]\nstruct MyPath {\n    id: u32,\n}\n\n// after\n#[derive(TypedPath, Deserialize)]\n#[typed_path(\"/users/{id}\")]\nstruct MyPath {\n    id: u32,\n}","handlingStrategy":"validation","validationCode":"// Safe invocation pattern: every TypedPath derive needs a `#[typed_path(\"...\")]` literal.\n#[derive(TypedPath, Deserialize)]\n#[typed_path(\"/users/{id}\")] // route literal is mandatory and must start with '/'\nstruct UsersShow {\n    id: u32,\n}\n\n// With a custom rejection, the path literal is still required:\n#[derive(TypedPath, Deserialize)]\n#[typed_path(\"/users/{id}\", rejection(MyRejection))]\nstruct UsersShow {\n    id: u32,\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pair #[derive(TypedPath)] with a #[typed_path(\"/...\")] attribute in the same commit.","Spell the attribute exactly typed_path; other names (path, route) are silently ignored and cause this error.","Ensure the route begins with '/'; otherwise a separate 'paths must start with a `/`' error fires.","Do not put generics on a TypedPath struct — generics are rejected with a different error upstream."],"tags":["axum","axum-macros","typed-path","routing","proc-macro","compile-error"],"backgroundTag":null,"analyzedSha":"151cd5c12325373b86daf405a6afc0a0086a6706","analyzedAt":"2026-08-11T16:57:37.422Z","contentChangedAt":"2026-08-11T16:57:37.422Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}