{"record":{"id":"16435fc65ea870b9","repo":"bevyengine/bevy","slug":"could-not-create-fetch-state-please-initialize-al","errorCode":null,"errorMessage":"Could not create fetch_state, Please initialize all referenced components before transmuting.","messagePattern":"Could not create fetch_state, Please initialize all referenced components before transmuting\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/bevy_ecs/src/query/state.rs","lineNumber":701,"sourceCode":"        &self,\n        world: impl Into<UnsafeWorldCell<'a>>,\n    ) -> QueryState<NewD> {\n        self.transmute_filtered::<NewD, ()>(world.into())\n    }\n\n    /// Creates a new [`QueryState`] with the same underlying [`FilteredAccess`], matched tables and archetypes\n    /// as self but with a new type signature.\n    ///\n    /// Panics if `NewD` or `NewF` require accesses that this query does not have.\n    pub fn transmute_filtered<'a, NewD: SingleEntityQueryData, NewF: QueryFilter>(\n        &self,\n        world: impl Into<UnsafeWorldCell<'a>>,\n    ) -> QueryState<NewD, NewF> {\n        let world = world.into();\n        self.validate_world(world.id());\n\n        let mut component_access = FilteredAccess::default();\n        let mut fetch_state = NewD::get_state(world.components()).expect(\"Could not create fetch_state, Please initialize all referenced components before transmuting.\");\n        let filter_state = NewF::get_state(world.components()).expect(\"Could not create filter_state, Please initialize all referenced components before transmuting.\");\n\n        let mut self_access = self.component_access.clone();\n        if D::IS_READ_ONLY {\n            // The current state was transmuted from a mutable\n            // `QueryData` to a read-only one.\n            // Ignore any write access in the current state.\n            self_access.access_mut().clear_writes();\n        }\n\n        NewD::update_component_access(&fetch_state, &mut component_access);\n        NewD::provide_extra_access(\n            &mut fetch_state,\n            component_access.access_mut(),\n            self_access.access(),\n        );\n\n        let mut filter_component_access = FilteredAccess::default();","sourceCodeStart":683,"sourceCodeEnd":719,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_ecs/src/query/state.rs#L683-L719","documentation":"Panic from QueryState::transmute_filtered: building the fetch state for the new query data failed because a component referenced by NewD has not been initialized/registered in the world yet. Transmutation reuses the old state's component ids, so any not-yet-initialized component in the new signature cannot be resolved.","triggerScenarios":"Thrown at crates/bevy_ecs/src/query/state.rs:701 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure all components referenced by the new query type are registered (spawn once, or world.init_component::<T>()) before transmuting","Transmute only between queries whose component sets are already initialized","Construct a fresh QueryState::new for the new signature instead"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}