bevyengine/bevy · error · QueryEntityError
The entity with ID {0} was requested mutably more than once
Error message
The entity with ID {0} was requested mutably more than once What it means
thiserror Display for QueryEntityError::AliasedMutability: Query::get_many_mut (or similar batched mutable access) received the same Entity more than once in its list. Two &mut bindings to one entity would alias mutable borrows, so the API validates for duplicates and reports the offending id.
Source
Thrown at crates/bevy_ecs/src/query/error.rs:23
entity::{Entity, EntityNotSpawnedError},
};
/// An error that occurs when retrieving a specific [`Entity`]'s query result from [`Query`](crate::system::Query) or [`QueryState`](crate::query::QueryState).
// TODO: return the type_name as part of this error
#[derive(thiserror::Error, Clone, Copy, Debug, PartialEq, Eq)]
pub enum QueryEntityError {
/// The given [`Entity`]'s components do not match the query.
///
/// 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)]View on GitHub (pinned to 396ca72708)
Solutions
- Deduplicate the entity list before calling get_many_mut
- Split overlapping entities into sequential get_mut calls
- Use a ParamSet or iter().find() pattern when the set of entities is not known disjoint
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/bevy_ecs/src/query/error.rs:23 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/c82328006b963f6f.
Report an issue: GitHub.