{"record":{"id":"b6f9c3120ce0f947","repo":"bevyengine/bevy","slug":"expected-a-template-type-path","errorCode":null,"errorMessage":"Expected a Template type path","messagePattern":"Expected a Template type path","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/bevy_ecs/macros/src/template.rs","lineNumber":366,"sourceCode":"        let is_pub = matches!(field.vis, syn::Visibility::Public(_));\n        let field_maybe_pub = if is_pub { quote!(pub) } else { quote!() };\n        let ident = &field.ident;\n        let ty = &field.ty;\n        let index = Index::from(index);\n        let mut template_type = TemplateType::FromTemplate;\n        for attr in &field.attrs {\n            if attr.path().is_ident(TEMPLATE_ATTRIBUTE) {\n                attr.parse_args_with(|stream: ParseStream| {\n                    let forked = stream.fork();\n                    let ident = forked.parse::<Ident>()?;\n                    if ident == BUILT_IN_ATTRIBUTE {\n                        stream.parse::<Ident>()?;\n                        template_type = TemplateType::BuiltIn;\n                    } else {\n                        if let Ok(path) = stream.parse::<Path>() {\n                            template_type = TemplateType::Manual(path);\n                        } else {\n                            return Err(syn::Error::new(\n                                attr.span(),\n                                \"Expected a Template type path\",\n                            ));\n                        }\n                    }\n                    Ok(())\n                })?;\n            }\n        }\n\n        let template_type = match template_type {\n            TemplateType::FromTemplate => {\n                quote!(<#ty as #bevy_ecs::template::FromTemplate>::Template)\n            }\n            TemplateType::BuiltIn => {\n                quote!(<#ty as #bevy_ecs::template::BuiltInTemplate>::Template)\n            }\n            TemplateType::Manual(path) => quote! {#path},","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_ecs/macros/src/template.rs#L348-L384","documentation":"Inside `#[derive(FromTemplate)]`, a field annotated `#[template(...)]` must contain either the ident `built_in` (use the built-in template machinery) or a valid type path naming a manual template type. The parser at template.rs:366 first tries an ident; if it is not `built_in` it tries `syn::Path`; if both fail it emits this syn::Error.","triggerScenarios":"`#[template(0)]`, `#[template(\"Foo\")]`, `#[template(true)]`, `#[template()]` (empty parens), or any attribute payload that is neither the `built_in` ident nor a parseable path like `my_mod::MyTemplate`. Note the payload must be a path, not a generic instantiation with brackets in some malformed form.","commonSituations":"Typos when copying the attribute from examples; assuming the attribute takes a literal or expression; version drift where the attribute grammar changed; leftover `#[template(...)]` from an abandoned experiment.","solutions":["Use a real type path: `#[template(my_templates::ItemTemplate)]`","Use the built-in form: `#[template(built_in)]`","Remove the `#[template]` attribute entirely so the field falls back to `TemplateType::FromTemplate`","Check the exact attribute spelling expected by your bevy_ecs version (TEMPLATE_ATTRIBUTE is `template`)"],"exampleFix":"// before\n#[derive(FromTemplate)]\nstruct Enemy {\n    #[template(0)]\n    loot: Item,\n}\n\n// after\n#[derive(FromTemplate)]\nstruct Enemy {\n    #[template(built_in)]\n    loot: Item,\n}\n// or: #[template(templates::ItemTemplate)] loot: Item,","handlingStrategy":"validation","validationCode":"cargo check --workspace # syn::Error from the attribute is reported with the exact span","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Attribute payload must be exactly `built_in` or a type path","Do not put literals, numbers, or expressions inside #[template(..)]","Omit the attribute when default FromTemplate behavior is wanted"],"tags":["rust","bevy","ecs","proc-macro","attribute","compile-time"],"backgroundTag":"macro-attribute-syntax-error","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T20:17:18.057Z"}