{"record":{"id":"b8e44564ac6126d4","repo":"bevyengine/bevy","slug":"has-access-conflicts-between-nested-queries-accesses","errorCode":null,"errorMessage":"`{}` has access conflicts between nested queries{accesses}.","messagePattern":"`(.+?)` has access conflicts between nested queries(.+?)\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/bevy_ecs/src/query/state.rs","lineNumber":351,"sourceCode":"    }\n\n    fn assert_no_conflicts_with_nested_queries(&self, world: UnsafeWorldCell<'_>) {\n        self.init_access(&mut FilteredAccessSet::new())\n            .unwrap_or_else(|access2| {\n                // Find the other conflicting query.\n                // By initializing `access` with the access of the later query,\n                // the earlier one will detect the conflict instead.\n                let mut access = access2.clone();\n                let access1 = self.init_access(&mut access).expect_err(\n                    \"Query with internal access conflict must always report a conflict\",\n                );\n                let conflicts = access1.get_conflicts(&access2);\n                let mut accesses = conflicts.format_conflict_list(world);\n                // Access list may be empty (if access to all components requested)\n                if !accesses.is_empty() {\n                    accesses.insert_str(0, \" on component(s) \");\n                }\n                panic!(\n                    \"`{}` has access conflicts between nested queries{accesses}.\",\n                    DebugName::type_name::<Self>().shortname()\n                );\n            });\n    }\n\n    /// Creates a [`Query`] from the given [`QueryState`] and [`World`].\n    ///\n    /// This will create read-only queries, see [`Self::query_mut`] for mutable queries.\n    pub fn query<'w, 's>(&'s mut self, world: &'w World) -> Query<'w, 's, D::ReadOnly, F> {\n        self.update_archetypes(world);\n        self.query_manual(world)\n    }\n\n    /// Creates a [`Query`] from the given [`QueryState`] and [`World`].\n    ///\n    /// This method is slightly more efficient than [`QueryState::query`] in some situations, since\n    /// it does not update this instance's internal cache. The resulting query may skip an entity that","sourceCodeStart":333,"sourceCodeEnd":369,"githubUrl":"https://github.com/bevyengine/bevy/blob/a62cce8c05ceacd3bd102e678c83e2b42e5dfbe2/crates/bevy_ecs/src/query/state.rs#L333-L369","documentation":"This panic comes from assert_no_conflicts_with_nested_queries on SystemState/QueryState: when a system/state contains nested queries (e.g. Query with Query inside), their component accesses overlap incompatibly (mut & read or two muts on the same components). Bevy detects the conflicting Access pairs at init and panics with the formatted conflict list.","triggerScenarios":"Declaring Query<(Query<&mut A>, &A)> or Query<(&mut A, Query<&A>)> (or param sets with nested queries) whose flattened accesses conflict; initializing the system triggers the check.","commonSituations":"Nesting queries inside a Query tuple for parent/child traversal and requesting the same component mutable in one and readable/mutable in the other.","solutions":["Split the conflicting accesses into disjoint components or use filters (With/Without) so accesses don't overlap","Wrap one of the conflicting queries in ParamSet","Restructure so the nested query only conflicts on entities via Without<Parent>-style exclusion"],"exampleFix":"// before\nfn system(q: Query<(Entity, &mut Transform, Query<&GlobalTransform>)>) {}\n\n// after\nfn system(mut set: ParamSet<(Query<&mut Transform>, Query<&GlobalTransform>)>) {}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Conflict is a hard panic at system init — catch via std::panic::catch_unwind during init in test harnesses:\nlet result = std::panic::catch_unwind(|| system.initialize(&mut world));","preventionTips":["Avoid nesting queries that touch the same components","Use ParamSet for overlapping query access","Add disjointness filters (With/Without) when queries overlap"],"tags":["bevy","ecs","queries","access-conflict"],"backgroundTag":"system-param-access-conflict","analyzedSha":"a62cce8c05ceacd3bd102e678c83e2b42e5dfbe2","analyzedAt":"2026-09-19T21:23:06.616Z","contentChangedAt":"2026-09-19T21:23:06.616Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}