bevyengine/bevy · error

`{type_path}` should be registered in type registry via `App

Error message

`{type_path}` should be registered in type registry via `App::register_type<{type_path}>`

What it means

`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.

Source

Thrown at crates/bevy_ecs/src/reflect/entity_commands.rs:368

        self.resource_scope(|entity, registry: Mut<T>| {
            let type_registry = registry.as_ref().as_ref();
            take_reflect_with_registry_ref(entity, type_registry, component_type_path)
        })
    }
}

/// Helper function to add a reflect component or bundle to a given entity
fn insert_reflect_with_registry_ref(
    entity: &mut EntityWorldMut,
    type_registry: &TypeRegistry,
    component: Box<dyn PartialReflect>,
) {
    let type_info = component
        .get_represented_type_info()
        .expect("component should represent a type.");
    let type_path = type_info.type_path();
    let Some(type_registration) = type_registry.get(type_info.type_id()) else {
        panic!("`{type_path}` should be registered in type registry via `App::register_type<{type_path}>`");
    };

    if let Some(reflect_component) = type_registration.data::<ReflectComponent>() {
        reflect_component.insert(entity, component.as_partial_reflect(), type_registry);
    } else if let Some(reflect_bundle) = type_registration.data::<ReflectBundle>() {
        reflect_bundle.insert(entity, component.as_partial_reflect(), type_registry);
    } else {
        panic!("`{type_path}` should have #[reflect(Component)] or #[reflect(Bundle)]");
    }
}

/// Helper function to remove a reflect component or bundle from a given entity
fn remove_reflect_with_registry_ref(
    entity: &mut EntityWorldMut,
    type_registry: &TypeRegistry,
    component_type_path: Cow<'static, str>,
) {
    let Some(type_registration) = type_registry.get_with_type_path(&component_type_path) else {

View on GitHub (pinned to 396ca72708)

Solutions

  1. Add `app.register_type::<T>()` in the plugin that owns `T`, before any systems or commands can run
  2. For bare-World code paths, register the type in the `TypeRegistry` you pass to the registry-ref variants of these APIs
  3. 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

Example fix

// before
entity.insert_reflect(Box::new(Mass(3.0))); // panics if Mass never registered

// after
app.register_type::<Mass>();
// ... systems/commands that insert_reflect(Mass) now resolve
Defensive patterns

Strategy: validation

Validate before calling

// Check registration before issuing the reflective command
let registry = app.world().resource::<AppTypeRegistry>();
if registry.read().contains::<MyComponent>() {
    entity.insert_reflect(Box::new(value));
} else {
    app.register_type::<MyComponent>();
}

Type guard

fn is_registered<T: Reflect + 'static>(registry: &TypeRegistry) -> bool { registry.contains(TypeId::of::<T>()) }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of bevyengine/bevy@396ca72708 (2026-08-20). Data as JSON: /api/errors/3db81a4ad026799c. Report an issue: GitHub.