bevyengine/bevy · error · QuerySingleError
No entities fit the query {0}
Error message
No entities fit the query {0} What it means
thiserror Display for QuerySingleError::NoEntities: a single-result API (Query::single, single_mut, single_inner) found zero matching entities where exactly one was expected. The DebugName in {0} identifies the query type that came up empty.
Source
Thrown at crates/bevy_ecs/src/query/error.rs:32
/// Either it does not have a requested component, or it has a component which the query filters out.
#[error("The query does not match entity {0}")]
QueryDoesNotMatch(Entity, ArchetypeId),
/// The given [`Entity`] is not spawned.
#[error("{0}")]
NotSpawned(#[from] EntityNotSpawnedError),
/// The [`Entity`] was requested mutably more than once.
///
/// See [`Query::get_many_mut`](crate::system::Query::get_many_mut) for an example.
#[error("The entity with ID {0} was requested mutably more than once")]
AliasedMutability(Entity),
}
/// An error that occurs when evaluating a [`Query`](crate::system::Query) or [`QueryState`](crate::query::QueryState) as a single expected result via
/// [`single`](crate::system::Query::single) or [`single_mut`](crate::system::Query::single_mut).
#[derive(Debug, thiserror::Error)]
pub enum QuerySingleError {
/// No entity fits the query.
#[error("No entities fit the query {0}")]
NoEntities(DebugName),
/// Multiple entities fit the query.
#[error("Multiple entities fit the query {0}")]
MultipleEntities(DebugName),
}
/// An error that occurs when creating a contiguous iterator from a non-dense [`Query`](crate::system::Query) or [`QueryState`](crate::query::QueryState) via
/// [`contiguous_iter`](crate::system::Query::contiguous_iter) or [`contiguous_iter_mut`](crate::system::Query::contiguous_iter_mut).
#[derive(Debug, thiserror::Error)]
#[error("Cannot contiguously iterate non-dense query {0}")]
pub struct QueryNotDenseError(pub DebugName);
#[cfg(test)]
mod test {
use crate::{prelude::World, query::QueryEntityError};
use bevy_ecs_macros::Component;
#[test]View on GitHub (pinned to 396ca72708)
Solutions
- Use Query::single() -> Option (or get_single) and handle None
- Ensure the expected entity actually matches the query (components present, filters pass)
- Spawn/insert the required components before the system runs
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at crates/bevy_ecs/src/query/error.rs:32 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/22e37642a889e83b.
Report an issue: GitHub.