bevyengine/bevy · error
Could not create fetch_state, Please initialize all referenc
Error message
Could not create fetch_state, Please initialize all referenced components before transmuting.
What it means
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.
Source
Thrown at crates/bevy_ecs/src/query/state.rs:701
&self,
world: impl Into<UnsafeWorldCell<'a>>,
) -> QueryState<NewD> {
self.transmute_filtered::<NewD, ()>(world.into())
}
/// Creates a new [`QueryState`] with the same underlying [`FilteredAccess`], matched tables and archetypes
/// as self but with a new type signature.
///
/// Panics if `NewD` or `NewF` require accesses that this query does not have.
pub fn transmute_filtered<'a, NewD: SingleEntityQueryData, NewF: QueryFilter>(
&self,
world: impl Into<UnsafeWorldCell<'a>>,
) -> QueryState<NewD, NewF> {
let world = world.into();
self.validate_world(world.id());
let mut component_access = FilteredAccess::default();
let mut fetch_state = NewD::get_state(world.components()).expect("Could not create fetch_state, Please initialize all referenced components before transmuting.");
let filter_state = NewF::get_state(world.components()).expect("Could not create filter_state, Please initialize all referenced components before transmuting.");
let mut self_access = self.component_access.clone();
if D::IS_READ_ONLY {
// The current state was transmuted from a mutable
// `QueryData` to a read-only one.
// Ignore any write access in the current state.
self_access.access_mut().clear_writes();
}
NewD::update_component_access(&fetch_state, &mut component_access);
NewD::provide_extra_access(
&mut fetch_state,
component_access.access_mut(),
self_access.access(),
);
let mut filter_component_access = FilteredAccess::default();View on GitHub (pinned to 396ca72708)
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/bevy_ecs/src/query/state.rs:701 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of bevyengine/bevy@396ca72708 (2026-08-20).
Data as JSON: /api/errors/16435fc65ea870b9.
Report an issue: GitHub.