{"record":{"id":"83397565d0e50239","repo":"bevyengine/bevy","slug":"the-query-does-not-match-entity-0","errorCode":null,"errorMessage":"The query does not match entity {0}","messagePattern":"The query does not match entity (.+?)","errorType":"exception","errorClass":"QueryEntityError","httpStatus":null,"severity":"error","filePath":"crates/bevy_ecs/src/query/error.rs","lineNumber":15,"sourceCode":"use bevy_utils::prelude::DebugName;\n\nuse crate::{\n    archetype::ArchetypeId,\n    entity::{Entity, EntityNotSpawnedError},\n};\n\n/// An error that occurs when retrieving a specific [`Entity`]'s query result from [`Query`](crate::system::Query) or [`QueryState`](crate::query::QueryState).\n// TODO: return the type_name as part of this error\n#[derive(thiserror::Error, Clone, Copy, Debug, PartialEq, Eq)]\npub enum QueryEntityError {\n    /// The given [`Entity`]'s components do not match the query.\n    ///\n    /// Either it does not have a requested component, or it has a component which the query filters out.\n    #[error(\"The query does not match entity {0}\")]\n    QueryDoesNotMatch(Entity, ArchetypeId),\n    /// The given [`Entity`] is not spawned.\n    #[error(\"{0}\")]\n    NotSpawned(#[from] EntityNotSpawnedError),\n    /// The [`Entity`] was requested mutably more than once.\n    ///\n    /// See [`Query::get_many_mut`](crate::system::Query::get_many_mut) for an example.\n    #[error(\"The entity with ID {0} was requested mutably more than once\")]\n    AliasedMutability(Entity),\n}\n\n/// An error that occurs when evaluating a [`Query`](crate::system::Query) or [`QueryState`](crate::query::QueryState) as a single expected result via\n/// [`single`](crate::system::Query::single) or [`single_mut`](crate::system::Query::single_mut).\n#[derive(Debug, thiserror::Error)]\npub enum QuerySingleError {\n    /// No entity fits the query.\n    #[error(\"No entities fit the query {0}\")]\n    NoEntities(DebugName),","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_ecs/src/query/error.rs#L1-L33","documentation":"thiserror Display for QueryEntityError::QueryDoesNotMatch: Query::get/get_mut was called with an Entity whose archetype does not satisfy the query — either it lacks a queried component or a filter (With/Without/Added/etc.) excludes it. The archetype id pinpoints which table row mismatched; the message names the entity in {0}.","triggerScenarios":"Thrown at crates/bevy_ecs/src/query/error.rs:15 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the entity actually has the queried components before calling get","Adjust the query filters (e.g. drop Without<> that excludes the archetype)","Use Query::contains_entity/get_many and branch on the Option/Result instead of assuming membership","Use an Option<Q> query parameter to tolerate absent components"],"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"}