bevyengine/bevy · error
Could not create filter_state, Please initialize all referen
Error message
Could not create filter_state, Please initialize all referenced components before transmuting.
What it means
Panic from QueryState::transmute_filtered: constructing the filter state (NewF) failed because a component used by the new filter is not initialized in the world, so its ComponentId/state could not be produced. Companion guard to the fetch-state check in the same method.
Source
Thrown at crates/bevy_ecs/src/query/state.rs:702
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();
NewF::update_component_access(&filter_state, &mut filter_component_access);View on GitHub (pinned to 396ca72708)
Solutions
- Register the filter's components with the world before transmuting (init_component or an initial spawn)
- Use a filter whose components are already part of the original query
- Build QueryState::new directly for the filtered query instead of transmuting
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/bevy_ecs/src/query/state.rs:702 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/25b7c7ee40c19636.
Report an issue: GitHub.