{"record":{"id":"614f803873dbf200","repo":"bevyengine/bevy","slug":"the-world-was-missing-the-apptyperegistry-reso","errorCode":null,"errorMessage":"The `World` was missing the `AppTypeRegistry` resource","messagePattern":"The `World` was missing the `AppTypeRegistry` resource","errorType":"exception","errorClass":"GetComponentReflectError::MissingAppTypeRegistry","httpStatus":null,"severity":"error","filePath":"crates/bevy_ecs/src/world/reflect.rs","lineNumber":239,"sourceCode":"    #[error(\"No `ComponentId` corresponding to {0:?} found (did you call App::register_type()?)\")]\n    NoCorrespondingComponentId(TypeId),\n\n    /// The given [`Entity`] does not have a [`Component`] corresponding to the given [`TypeId`].\n    #[error(\"The given `Entity` {entity} does not have a `{component_name:?}` component ({component_id:?}, which corresponds to {type_id:?})\")]\n    EntityDoesNotHaveComponent {\n        /// The given [`Entity`].\n        entity: Entity,\n        /// The given [`TypeId`].\n        type_id: TypeId,\n        /// The [`ComponentId`] corresponding to the given [`TypeId`].\n        component_id: ComponentId,\n        /// The name corresponding to the [`Component`] with the given [`TypeId`], or `None`\n        /// if not available.\n        component_name: Option<DebugName>,\n    },\n\n    /// The [`World`] was missing the [`AppTypeRegistry`] resource.\n    #[error(\"The `World` was missing the `AppTypeRegistry` resource\")]\n    MissingAppTypeRegistry,\n\n    /// The [`World`]'s [`TypeRegistry`] did not contain [`TypeData`] for [`ReflectFromPtr`] for the given [`TypeId`].\n    ///\n    /// This is usually handled by calling [`App::register_type`] for the type corresponding to\n    /// the given [`TypeId`].\n    ///\n    /// See the documentation for [`bevy_reflect`] for more information.\n    ///\n    /// [`TypeData`]: bevy_reflect::TypeData\n    /// [`TypeRegistry`]: bevy_reflect::TypeRegistry\n    /// [`ReflectFromPtr`]: bevy_reflect::ReflectFromPtr\n    /// [`App::register_type`]: ../../../bevy_app/struct.App.html#method.register_type\n    #[error(\"The `World`'s `TypeRegistry` did not contain `TypeData` for `ReflectFromPtr` for the given {0:?} (did you call `App::register_type()`?)\")]\n    MissingReflectFromPtrTypeData(TypeId),\n}\n\n#[cfg(test)]","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_ecs/src/world/reflect.rs#L221-L257","documentation":"GetComponentReflectError::MissingAppTypeRegistry is returned by World::get_reflect / get_reflect_mut when the World has no AppTypeRegistry resource, which is the shared bevy_reflect TypeRegistry that reflective component access depends on. bevy_app inserts this resource when an App is built, so hitting this error almost always means you are using a bare World (or stripped one) that never went through App bootstrap.","triggerScenarios":"Calling world.get_reflect / get_reflect_mut on a manually constructed World (unit tests, benchmarks, tooling) without inserting AppTypeRegistry; a World cleared with clear_resources()/clear_all() that dropped the registry; a sub-world created manually for extraction that is missing the registry resource.","commonSituations":"Unit tests that do `let mut world = World::new();` and then exercise reflection helpers; procedural tooling that spawns isolated Worlds; refactors that moved reflective code from an App-driven system into a raw-World context.","solutions":["Insert the registry into the bare World: world.insert_resource(AppTypeRegistry::default()) (then register the types you need, e.g. registry.write().register::<T>()).","Prefer building a minimal App in tests (App::new() plus the needed plugins) so bootstrap resources exist.","If the World was cleared, re-insert AppTypeRegistry after clear_resources/clear_all.","Guard with world.get_resource::<AppTypeRegistry>().is_some() before doing reflective work and skip/fail softly."],"exampleFix":"// before\nlet mut world = World::new();\nlet c = world.get_reflect(entity, TypeId::of::<Health>())?; // MissingAppTypeRegistry\n\n// after\nuse bevy_ecs::reflect::AppTypeRegistry;\nlet mut world = World::new();\nlet registry = AppTypeRegistry::default();\nregistry.write().register::<Health>();\nworld.insert_resource(registry);\nlet c = world.get_reflect(entity, TypeId::of::<Health>())?;","handlingStrategy":"validation","validationCode":"if world.get_resource::<AppTypeRegistry>().is_none() {\n    let registry = AppTypeRegistry::default();\n    registry.write().register::<T>();\n    world.insert_resource(registry);\n}","typeGuard":null,"tryCatchPattern":"match world.get_reflect(entity, TypeId::of::<T>()) {\n    Err(GetComponentReflectError::MissingAppTypeRegistry) => {\n        // initialize registry or fall back to typed access\n    }\n    other => { /* ... */ }\n}","preventionTips":["Use App::new() (with needed plugins) instead of bare World::new() wherever reflection is exercised.","After clear_resources/clear_all, re-insert AppTypeRegistry before reflective calls.","Keep a helper that ensures AppTypeRegistry exists in test harnesses."],"tags":["bevy","ecs","reflect","app-type-registry","bootstrap","world"],"backgroundTag":"missing-type-registry","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"}