{"record":{"id":"6a8e22feaa4c813f","repo":"bevyengine/bevy","slug":"type-path-must-be-a-string-literal","errorCode":null,"errorMessage":"`#[type_path = \"...\"]` must be a string literal","messagePattern":"`#\\[type_path = \"\\.\\.\\.\"\\]` must be a string literal","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/bevy_reflect/derive/src/derive_data.rs","lineNumber":217,"sourceCode":"                Meta::List(meta_list) if meta_list.path.is_ident(REFLECT_ATTRIBUTE_NAME) => {\n                    if let MacroDelimiter::Paren(_) = meta_list.delimiter {\n                        container_attributes.parse_meta_list(meta_list, provenance.trait_)?;\n                    } else {\n                        return Err(syn::Error::new(\n                            meta_list.delimiter.span().join(),\n                            format_args!(\n                                \"`#[{REFLECT_ATTRIBUTE_NAME}(\\\"...\\\")]` must use parentheses `(` and `)`\"\n                            ),\n                        ));\n                    }\n                }\n                Meta::NameValue(pair) if pair.path.is_ident(TYPE_PATH_ATTRIBUTE_NAME) => {\n                    let syn::Expr::Lit(syn::ExprLit {\n                        lit: syn::Lit::Str(lit),\n                        ..\n                    }) = &pair.value\n                    else {\n                        return Err(syn::Error::new(\n                            pair.span(),\n                            format_args!(\"`#[{TYPE_PATH_ATTRIBUTE_NAME} = \\\"...\\\"]` must be a string literal\"),\n                        ));\n                    };\n\n                    custom_path = Some(syn::parse::Parser::parse_str(\n                        parse_path_no_leading_colon,\n                        &lit.value(),\n                    )?);\n                }\n                Meta::NameValue(pair) if pair.path.is_ident(TYPE_NAME_ATTRIBUTE_NAME) => {\n                    let syn::Expr::Lit(syn::ExprLit {\n                        lit: syn::Lit::Str(lit),\n                        ..\n                    }) = &pair.value\n                    else {\n                        return Err(syn::Error::new(\n                            pair.span(),","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_reflect/derive/src/derive_data.rs#L199-L235","documentation":"`#[type_path = \"...\"]` overrides the module path bevy_reflect reports for a type. The value must be a string literal containing a valid Rust path without a leading `::`: `derive_data.rs` (crates/bevy_reflect/derive/src/derive_data.rs:210) matches `syn::Lit::Str` and then parses the contents with `parse_path_no_leading_colon`. Anything else — an unquoted path, a number, an expression — fails with \"`#[type_path = \\\"...\\\"]` must be a string literal\".","triggerScenarios":"Writing `#[type_path = my_crate::net]` (unquoted path) or any non-string-literal value; a quoted value with a leading `::` (`\"::my_crate::net\"`) also fails, at the subsequent path parse.","commonSituations":"Renaming crates and hand-editing the attribute; macro-generated type_path attributes where the value wasn't stringified; muscle memory from `#[serde(crate = \"...\")]`-style values that are parsed differently.","solutions":["Quote the value: `#[type_path = \"my_crate::net\"]`","Drop any leading `::` from the path inside the string","In macros, use `stringify!` or `$crate`-based `concat!` to build the string literal"],"exampleFix":"// before\n#[type_path = my_crate::net]\nstruct Packet;\n\n// after\n#[type_path = \"my_crate::net\"]\nstruct Packet;","handlingStrategy":"validation","validationCode":"null","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Quote type_path values and omit the leading `::`: #[type_path = \"crate::module\"]","In macros, build the string with concat!/stringify! rather than pasting a raw path"],"tags":["bevy","reflect","derive-macro","type-path","attribute-syntax","compile-error"],"backgroundTag":"invalid-derive-attribute-syntax","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}