{"record":{"id":"3b1d6646b66aabed","repo":"bevyengine/bevy","slug":"joining-queries-initialized-on-different-worlds-is","errorCode":null,"errorMessage":"Joining queries initialized on different worlds is not allowed.","messagePattern":"Joining queries initialized on different worlds is not allowed\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/bevy_ecs/src/query/state.rs","lineNumber":813,"sourceCode":"    /// Use this to combine two queries. The data accessed will be the intersection\n    /// of archetypes included in both queries.\n    ///\n    /// ## Panics\n    ///\n    /// Will panic if `NewD` or `NewF` requires accesses not in `Q` or `OtherQ`.\n    pub fn join_filtered<\n        'a,\n        OtherD: QueryData,\n        OtherF: QueryFilter,\n        NewD: SingleEntityQueryData,\n        NewF: QueryFilter,\n    >(\n        &self,\n        world: impl Into<UnsafeWorldCell<'a>>,\n        other: &QueryState<OtherD, OtherF>,\n    ) -> QueryState<NewD, NewF> {\n        if self.world_id != other.world_id {\n            panic!(\"Joining queries initialized on different worlds is not allowed.\");\n        }\n\n        let world = world.into();\n\n        self.validate_world(world.id());\n\n        let mut component_access = FilteredAccess::default();\n        let mut new_fetch_state = NewD::get_state(world.components())\n            .expect(\"Could not create fetch_state, Please initialize all referenced components before transmuting.\");\n        let new_filter_state = NewF::get_state(world.components())\n            .expect(\"Could not create filter_state, Please initialize all referenced components before transmuting.\");\n\n        let mut joined_component_access = self.component_access.clone();\n        joined_component_access.extend(&other.component_access);\n\n        if D::IS_READ_ONLY && self.component_access.access().has_any_write()\n            || OtherD::IS_READ_ONLY && other.component_access.access().has_any_write()\n        {","sourceCodeStart":795,"sourceCodeEnd":831,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_ecs/src/query/state.rs#L795-L831","documentation":"Panic from QueryState::join_filtered: the two QueryStates being joined were created against different Worlds (their world_id fields differ). A joined query's tables/archetypes are only valid relative to one world, so this guard rejects cross-world joins as unsound.","triggerScenarios":"Thrown at crates/bevy_ecs/src/query/state.rs:813 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Recreate one of the QueryStates against the same World before joining","Initialize both states from the target world (e.g. world.query::<Q>())","Avoid persisting QueryState across world instances"],"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"}