{"record":{"id":"3db81a4ad026799c","repo":"bevyengine/bevy","slug":"type-path-should-be-registered-in-type-registr","errorCode":null,"errorMessage":"`{type_path}` should be registered in type registry via `App::register_type<{type_path}>`","messagePattern":"`(.+?)` should be registered in type registry via `App::register_type<(.+?)>`","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/bevy_ecs/src/reflect/entity_commands.rs","lineNumber":368,"sourceCode":"        self.resource_scope(|entity, registry: Mut<T>| {\n            let type_registry = registry.as_ref().as_ref();\n            take_reflect_with_registry_ref(entity, type_registry, component_type_path)\n        })\n    }\n}\n\n/// Helper function to add a reflect component or bundle to a given entity\nfn insert_reflect_with_registry_ref(\n    entity: &mut EntityWorldMut,\n    type_registry: &TypeRegistry,\n    component: Box<dyn PartialReflect>,\n) {\n    let type_info = component\n        .get_represented_type_info()\n        .expect(\"component should represent a type.\");\n    let type_path = type_info.type_path();\n    let Some(type_registration) = type_registry.get(type_info.type_id()) else {\n        panic!(\"`{type_path}` should be registered in type registry via `App::register_type<{type_path}>`\");\n    };\n\n    if let Some(reflect_component) = type_registration.data::<ReflectComponent>() {\n        reflect_component.insert(entity, component.as_partial_reflect(), type_registry);\n    } else if let Some(reflect_bundle) = type_registration.data::<ReflectBundle>() {\n        reflect_bundle.insert(entity, component.as_partial_reflect(), type_registry);\n    } else {\n        panic!(\"`{type_path}` should have #[reflect(Component)] or #[reflect(Bundle)]\");\n    }\n}\n\n/// Helper function to remove a reflect component or bundle from a given entity\nfn remove_reflect_with_registry_ref(\n    entity: &mut EntityWorldMut,\n    type_registry: &TypeRegistry,\n    component_type_path: Cow<'static, str>,\n) {\n    let Some(type_registration) = type_registry.get_with_type_path(&component_type_path) else {","sourceCodeStart":350,"sourceCodeEnd":386,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_ecs/src/reflect/entity_commands.rs#L350-L386","documentation":"`insert_reflect`/`remove_reflect` look the value's type up in the app's `TypeRegistry` to find its registration. If the type was never registered with `App::register_type`, the lookup by `type_id()` fails and the helper panics, telling you to register it. Registration is what makes `ReflectComponent`/`ReflectBundle` data discoverable by path or id.","triggerScenarios":"Calling `entity.insert_reflect(value)` or `entity.remove_reflect(type_path)` for a type that was never registered via `app.register_type::<T>()` in this app or bare `World` — including cases where the registering plugin has not run yet when the command applies.","commonSituations":"Plugin ordering bugs (a reflected insert executes before the plugin that registers the type); tests driving a raw `World` plus `AppTypeRegistry` without registering; using a type defined in another crate and assuming the dependency registers it.","solutions":["Add `app.register_type::<T>()` in the plugin that owns `T`, before any systems or commands can run","For bare-World code paths, register the type in the `TypeRegistry` you pass to the registry-ref variants of these APIs","If the type comes from a dependency, register it explicitly in your app's plugin setup rather than relying on the dependency to do it"],"exampleFix":"// before\nentity.insert_reflect(Box::new(Mass(3.0))); // panics if Mass never registered\n\n// after\napp.register_type::<Mass>();\n// ... systems/commands that insert_reflect(Mass) now resolve","handlingStrategy":"validation","validationCode":"// Check registration before issuing the reflective command\nlet registry = app.world().resource::<AppTypeRegistry>();\nif registry.read().contains::<MyComponent>() {\n    entity.insert_reflect(Box::new(value));\n} else {\n    app.register_type::<MyComponent>();\n}","typeGuard":"fn is_registered<T: Reflect + 'static>(registry: &TypeRegistry) -> bool { registry.contains(TypeId::of::<T>()) }","tryCatchPattern":null,"preventionTips":["Register types in the plugin that defines them so registration always precedes use","In tests with a bare World, mirror the app's register_type calls in the test harness","Assert registration early: a startup system that verifies required types are in AppTypeRegistry fails fast"],"tags":["bevy","reflection","type-registry","registration","panic"],"backgroundTag":"type-registry-missing-registration","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}