{"record":{"id":"927f78966cc07cb6","repo":"bevyengine/bevy","slug":"cannot-cache-scene-components-with-props-fields","errorCode":null,"errorMessage":"Cannot cache Scene Components with props/fields","messagePattern":"Cannot cache Scene Components with props/fields","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/bevy_scene/macros/src/bsn/parse.rs","lineNumber":249,"sourceCode":"        }\n\n        Ok(if input.peek(LitStr) {\n            let path = input.parse::<LitStr>()?;\n            if cached.is_none() {\n                return Err(syn::Error::new(\n                    path.span(),\n                    \"Cannot use scene assets without caching, please add the ':' prefix.\",\n                ));\n            }\n            BsnScene::Asset(path)\n        } else if input.peek(Brace) {\n            err_if_cached(\"Cannot cache scene expressions\")?;\n            BsnScene::Expression(braced_tokens(input)?)\n        } else if input.peek(At) {\n            input.parse::<At>()?;\n            let sc = input.parse::<BsnType>()?;\n            if sc.fields.len() > 0 {\n                err_if_cached(\"Cannot cache Scene Components with props/fields\")?;\n            }\n            BsnScene::SceneComponent(sc)\n        } else {\n            // PERF: do we really need this fork here?\n            let path = input.fork().parse::<Path>()?;\n            match PathType::new(&path) {\n                PathType::Type | PathType::Enum => {\n                    // Scene components are parsed before this if an @ is found.\n                    // If this path is hit, that means it wasn't prefixed by @\n                    return Err(syn::Error::new(\n                        path.span(),\n                        format!(\n                            \"Scene component {} needs to be prefixed by '@'\",\n                            path_to_string(&path),\n                        ),\n                    ));\n                }\n                PathType::Function | PathType::TypeFunction => {","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_scene/macros/src/bsn/parse.rs#L231-L267","documentation":"The @-prefixed scene-component form (@MySceneComponent) parses a BsnType; if it has fields/props, err_if_cached rejects it under a ':' cache prefix — only fieldless scene components are cacheable in principle. As with the expression case, the earlier 'caching is only supported for scene assets' check (parse.rs:229-231) intercepts ':' + non-literal first today, so this message is the guard kept for when asset-only caching is relaxed.","triggerScenarios":"Writing :@MySceneComponent { field: value } — a cached scene component that carries fields (currently surfaced as the 'only scene assets' error due to the earlier check).","commonSituations":"Marking data-rich scene components as cached; assuming ':' works uniformly across all BSN scene forms.","solutions":["Remove the ':' prefix from the scene component: @MySceneComponent { field: value }","If you need caching, put the content in a scene asset and load it with :\"path.scene\" instead"],"exampleFix":"// before\nbsn!(:@MySceneComponent { speed: 10.0 });\n\n// after\nbsn!(@MySceneComponent { speed: 10.0 });","handlingStrategy":"validation","validationCode":"// Rule: @SceneComponent forms take no ':' prefix; if the component has\n// fields, caching is not an option at all today.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Write @SceneComponent entries without the ':' prefix","Fieldless or not, prefer scene assets (\":\"path\") when caching behavior is required"],"tags":["bevy","bsn","proc-macro","scene-component","compile-error"],"backgroundTag":"proc-macro-syntax-error","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"}