{"record":{"id":"08a3ac808a5860c0","repo":"bevyengine/bevy","slug":"cannot-call-reflectcomponent-apply-on-component","errorCode":null,"errorMessage":"Cannot call `ReflectComponent::apply` on component {name}. It is immutable, and cannot modified through reflection","messagePattern":"Cannot call `ReflectComponent::apply` on component (.+?)\\. It is immutable, and cannot modified through reflection","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/bevy_ecs/src/reflect/component.rs","lineNumber":324,"sourceCode":"    }\n}\n\nimpl<C: Component + Reflect + TypePath> CreateTypeData<C> for ReflectComponent {\n    fn create_type_data(_input: ()) -> Self {\n        // TODO: Currently we panic if a component is immutable and you use\n        // reflection to mutate it. Perhaps the mutation methods should be fallible?\n        ReflectComponent(ReflectComponentFns {\n            insert: |entity, reflected_component, registry| {\n                let component = entity.world_scope(|world| {\n                    from_reflect_with_fallback::<C>(reflected_component, world, registry)\n                });\n                entity.insert(component);\n            },\n            apply: |mut entity, reflected_component| {\n                if !C::Mutability::MUTABLE {\n                    let name = DebugName::type_name::<C>();\n                    let name = name.shortname();\n                    panic!(\"Cannot call `ReflectComponent::apply` on component {name}. It is immutable, and cannot modified through reflection\");\n                }\n\n                // SAFETY: guard ensures `C` is a mutable component\n                let mut component = unsafe { entity.get_mut_assume_mutable::<C>() }.unwrap();\n                component.apply(reflected_component);\n            },\n            apply_or_insert_mapped: |entity,\n                                     reflected_component,\n                                     registry,\n                                     mut mapper,\n                                     relationship_hook_mode| {\n                if C::Mutability::MUTABLE {\n                    // SAFETY: guard ensures `C` is a mutable component\n                    if let Some(mut component) = unsafe { entity.get_mut_assume_mutable::<C>() } {\n                        component.apply(reflected_component.as_partial_reflect());\n                        C::map_entities(&mut component, &mut mapper);\n                    } else {\n                        let mut component = entity.world_scope(|world| {","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_ecs/src/reflect/component.rs#L306-L342","documentation":"Panics inside the ReflectComponentFns::apply closure when code attempts to mutate a component through reflection while the component was registered as immutable (Component<Mutability = Immutable>). ReflectComponent has no fallible mutation API, so the mutation is rejected by panicking.","triggerScenarios":"Thrown at crates/bevy_ecs/src/reflect/component.rs:324 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Do not mutate immutable components via ReflectComponent::apply; treat them as read-only","Declare the component as mutable (remove the Immutable mutability parameter) if reflective mutation is required","Read the component value via reflection and write a new value through a dedicated command/system instead"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}