{"record":{"id":"ebba54b68e2895fc","repo":"bevyengine/bevy","slug":"the-componentinfo-could-not-be-found","errorCode":null,"errorMessage":"the `ComponentInfo` could not be found","messagePattern":"the `ComponentInfo` could not be found","errorType":"exception","errorClass":"GetEntityMutByIdError::InfoNotFound","httpStatus":null,"severity":"error","filePath":"crates/bevy_ecs/src/world/unsafe_world_cell.rs","lineNumber":1222,"sourceCode":"    }\n\n    /// Returns the [`Tick`] at which this entity has been spawned.\n    pub fn spawn_tick(self) -> Tick {\n        // SAFETY: UnsafeEntityCell is only constructed for living entities and offers no despawn method\n        unsafe {\n            self.world()\n                .entities()\n                .entity_get_spawned_or_despawned_unchecked(self.entity)\n                .1\n        }\n    }\n}\n\n/// Error that may be returned when calling [`UnsafeEntityCell::get_mut_by_id`].\n#[derive(Debug, Clone, Copy, PartialEq, Eq, Error)]\npub enum GetEntityMutByIdError {\n    /// The [`ComponentInfo`](crate::component::ComponentInfo) could not be found.\n    #[error(\"the `ComponentInfo` could not be found\")]\n    InfoNotFound,\n    /// The [`Component`] is immutable. Creating a mutable reference violates its\n    /// invariants.\n    #[error(\"the `Component` is immutable\")]\n    ComponentIsImmutable,\n    /// This [`Entity`] does not have the desired [`Component`].\n    #[error(\"the `Component` could not be found\")]\n    ComponentNotFound,\n}\n\nimpl<'w> UnsafeWorldCell<'w> {\n    #[inline]\n    /// # Safety\n    /// - the returned `Table` is only used in ways that this [`UnsafeWorldCell`] has permission for.\n    /// - the returned `Table` is only used in ways that would not conflict with any existing borrows of world data.\n    unsafe fn fetch_table(self, location: EntityLocation) -> Option<&'w Table> {\n        // SAFETY:\n        // - caller ensures returned data is not misused and we have not created any borrows of component/resource data","sourceCodeStart":1204,"sourceCodeEnd":1240,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_ecs/src/world/unsafe_world_cell.rs#L1204-L1240","documentation":"GetEntityMutByIdError::InfoNotFound is returned by UnsafeEntityCell::get_mut_by_id when the ComponentId you pass has no ComponentInfo in the world's component registry — i.e. the id was never allocated by THIS world. ComponentIds are world-local indices; using one from another World, or an id created before a world reset (clear_all reallocates ids), yields this error instead of a pointer.","triggerScenarios":"Calling unsafe_entity_cell.get_mut_by_id(component_id) with a ComponentId captured from a different World (main vs render sub-world), from a previous run of a reset World, or an id you constructed/hand-indexed rather than obtained via world.components().component_id::<T>() / get_component_id().","commonSituations":"Unsafe/Schedule-internal code or performance-critical per-component access where ids are cached for speed; multi-world extraction pipelines copying ids between worlds; long-lived caches of ComponentId surviving world rebuilds in editor workflows.","solutions":["Resolve ids per-world: call world.components().component_id::<T>() (or register_component::<T>()) on the same World whose cell you hold.","Invalidate cached ComponentIds whenever the World is cleared/rebuilt; treat them as world-scoped, not global.","Validate before the unsafe call: world.components().get_info(id).is_some(); this is the exact condition that produces InfoNotFound.","Handle the Result by matching GetEntityMutByIdError instead of unwrapping, since this API is already fallible."],"exampleFix":"// before\nlet ptr = cell.get_mut_by_id(cached_id).unwrap(); // InfoNotFound: id from another world\n\n// after\nlet id = cell.world().components().component_id::<T>()\n    .expect(\"component registered in this world\");\nmatch cell.get_mut_by_id(id) {\n    Ok(Some(mut c)) => { /* ... */ }\n    Ok(None) => {}\n    Err(GetEntityMutByIdError::InfoNotFound) => debug!(\"unknown ComponentId {id:?}\"),\n    Err(e) => debug!(\"{e}\"),\n}","handlingStrategy":"try-catch","validationCode":"let valid = world\n    .components()\n    .get_info(component_id)\n    .is_some();\nif !valid { /* resolve id from this world: */\n    let component_id = world.components().component_id::<T>().unwrap();\n}","typeGuard":null,"tryCatchPattern":"match cell.get_mut_by_id(component_id) {\n    Ok(value) => { /* ... */ }\n    Err(GetEntityMutByIdError::InfoNotFound) => {\n        // id not from this world: re-resolve and retry once, or skip\n    }\n    Err(e) => { /* ... */ }\n}","preventionTips":["Treat ComponentId as world-scoped: resolve via world.components() on the same world you access.","Never cache ComponentIds across world clear/rebuild cycles.","Since get_mut_by_id already returns Result, always match instead of unwrap in unsafe plumbing."],"tags":["bevy","ecs","unsafe-world-cell","component-id","unsafe"],"backgroundTag":"invalid-component-id","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}