{"record":{"id":"97efc34915d406fc","repo":"bevyengine/bevy","slug":"world-contains-the-unregistered-component-type-p","errorCode":null,"errorMessage":"world contains the unregistered component `{type_path}`. consider adding `#[reflect(Component)]` to your type","messagePattern":"world contains the unregistered component `(.+?)`\\. consider adding `#\\[reflect\\(Component\\)\\]` to your type","errorType":"exception","errorClass":"WorldInstanceSpawnError","httpStatus":null,"severity":"error","filePath":"crates/bevy_world_serialization/src/world_asset_spawner.rs","lineNumber":112,"sourceCode":"    // apart and not reload the  in setthose cases as it's unlikely to be an actual asset change.\n    debounced_world_asset_events: HashMap<AssetId<WorldAsset>, u32>,\n    dynamic_world_asset_event_reader: MessageCursor<AssetEvent<DynamicWorld>>,\n    // TODO: temp fix for https://github.com/bevyengine/bevy/issues/12756 effect on dynamic worlds\n    // See debounced_world_asset_events\n    debounced_dynamic_world_asset_events: HashMap<AssetId<DynamicWorld>, u32>,\n    world_assets_to_spawn: Vec<(Handle<WorldAsset>, InstanceId, Option<Entity>)>,\n    dynamic_worlds_to_spawn: Vec<(Handle<DynamicWorld>, InstanceId, Option<Entity>)>,\n    world_assets_to_despawn: Vec<AssetId<WorldAsset>>,\n    dynamic_worlds_to_despawn: Vec<AssetId<DynamicWorld>>,\n    instances_to_despawn: Vec<InstanceId>,\n    instances_ready: Vec<(InstanceId, Option<Entity>)>,\n}\n\n/// Errors that can occur when spawning a world asset.\n#[derive(Error, Debug)]\npub enum WorldInstanceSpawnError {\n    /// `WorldAsset` contains an unregistered component type.\n    #[error(\"world contains the unregistered component `{type_path}`. consider adding `#[reflect(Component)]` to your type\")]\n    UnregisteredComponent {\n        /// Type of the unregistered component.\n        type_path: String,\n    },\n    /// `WorldAsset` contains an unregistered resource type.\n    #[error(\"world contains the unregistered resource `{type_path}`. consider adding `#[reflect(Resource)]` to your type\")]\n    UnregisteredResource {\n        /// Type of the unregistered resource.\n        type_path: String,\n    },\n    /// `WorldAsset` contains an unregistered type.\n    #[error(\n        \"world contains the unregistered type `{std_type_name}`. \\\n        consider reflecting it with `#[derive(Reflect)]` \\\n        and registering the type using `app.register_type::<T>()`\"\n    )]\n    UnregisteredType {\n        /// The [type name](std::any::type_name) for the unregistered type.","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_world_serialization/src/world_asset_spawner.rs#L94-L130","documentation":"When bevy_world_serialization spawns a saved World into your app, it reflectively instantiates every component stored in the asset. Each component type must be registered in the app's type registry AND flagged as a component via #[reflect(Component)] (resources via #[reflect(Resource)]). If a stored component's type_path has no such registration, spawning returns WorldInstanceSpawnError::UnregisteredComponent with \"world contains the unregistered component `{type_path}`. consider adding `#[reflect(Component)]` to your type\".","triggerScenarios":"Spawning a .world asset serialized from an app that had component types your app has not registered; forgetting app.register_type::<T>() for a component included in the world; deriving Reflect without #[reflect(Component)]; missing the plugin that owns and registers the component.","commonSituations":"Sharing world saves between projects or across team members whose apps register different types; modular apps where the serialized world includes types from a plugin that the loading scene forgot to add; upgrading Bevy and moving components into new crates without updating registrations.","solutions":["Add #[derive(Component, Reflect)] with #[reflect(Component)] to the listed type (and #[reflect(Resource)] for resources).","Register the type at startup: app.register_type::<TheListedType>(); — the error message names the exact type_path to register.","Make sure the plugin that owns/registers the component is actually added to the App before spawning the world.","Keep a single register_all_types-style registration list shared by both the exporter and importer apps so serialized sets stay in sync."],"exampleFix":"// before\n#[derive(Component, Reflect)]\nstruct Health(u32); // no #[reflect(Component)], or never registered\n\n// after\n#[derive(Component, Reflect)]\n#[reflect(Component)]\nstruct Health(u32);\n\n// and at startup:\napp.register_type::<Health>();","handlingStrategy":"try-catch","validationCode":"// ensure every component type in a world save is registered before spawning\nfn assert_registered<T: bevy::reflect::GetTypeRegistration>(app: &mut App) {\n    app.register_type::<T>();\n}","typeGuard":null,"tryCatchPattern":"match world_spawner.spawn_sync(&mut world, &world_handle) {\n    Ok(instance) => { info!(\"spawned world instance {instance:?}\"); }\n    Err(WorldInstanceSpawnError::UnregisteredComponent { type_path }) => {\n        error!(\"{type_path} is not registered — add #[reflect(Component)] and App::register_type::<{type_path}>()\");\n    }\n    Err(e) => error!(\"world spawn failed: {e}\"),\n}","preventionTips":["Register every reflected component/resource in the plugin that defines it, so adding the plugin is sufficient.","Share one registration list (or app.register_type_data audits) between exporter and importer apps.","Treat the error's type_path as the exact todo list; fix and restart.","Add an integration test that spawns each shipped .world asset to catch drift at CI time."],"tags":["rust","bevy","reflection","serialization","world","type-registry","spawn"],"backgroundTag":"unregistered-reflect-type","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"}