{"record":{"id":"4cd6283ca88eb13d","repo":"bevyengine/bevy","slug":"system-with-key-does-not-exist-in-the-schedul","errorCode":null,"errorMessage":"System with key {:?} does not exist in the schedule","messagePattern":"System with key (.+?) does not exist in the schedule","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/bevy_ecs/src/schedule/node.rs","lineNumber":649,"sourceCode":"                            // for example 2 systems with `Query<EntityMut>`\n                            conflicting_systems.push((a, b, Box::new([])));\n                        }\n                    }\n                }\n            }\n        }\n\n        ConflictingSystems(conflicting_systems)\n    }\n}\n\nimpl Index<SystemKey> for Systems {\n    type Output = SystemWithAccess;\n\n    #[track_caller]\n    fn index(&self, key: SystemKey) -> &Self::Output {\n        self.get(key)\n            .unwrap_or_else(|| panic!(\"System with key {:?} does not exist in the schedule\", key))\n    }\n}\n\nimpl IndexMut<SystemKey> for Systems {\n    #[track_caller]\n    fn index_mut(&mut self, key: SystemKey) -> &mut Self::Output {\n        self.get_mut(key)\n            .unwrap_or_else(|| panic!(\"System with key {:?} does not exist in the schedule\", key))\n    }\n}\n\n/// Pairs of systems that conflict with each other along with the components\n/// they conflict on, which prevents them from running in parallel. If the\n/// component list is empty, the systems conflict on [`World`] access in general\n/// (e.g. one of them is exclusive, or both systems have `Query<EntityMut>`).\n#[derive(Clone, Debug, Default)]\npub struct ConflictingSystems(pub Vec<(SystemKey, SystemKey, Box<[ComponentId]>)>);\n","sourceCodeStart":631,"sourceCodeEnd":667,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_ecs/src/schedule/node.rs#L631-L667","documentation":"Panics when the schedule's system container (Systems, a slot map) is indexed with a SystemKey that is not live: systems[key] via the Index impl. Keys are slot-map handles scoped to one container; a removed system frees its key, and keys from another schedule were never valid. Almost always indicates stale or foreign keys, not a Bevy bug.","triggerScenarios":"Indexing with a key captured from a different Schedule; holding a SystemKey across a schedule change that removed the system; editor/stepping/debug tooling or custom executors re-using keys cached before a schedule rebuild.","commonSituations":"Editor or stepping UIs that cache SystemKeys between frames while systems are added/removed; plugins storing keys in resources that outlive the schedule they came from; refactors that mix keys from two schedules.","solutions":["Replace indexing with systems.get(key) and handle the None case explicitly.","Re-fetch keys from the owning schedule after any modification/rebuild instead of caching them.","Verify the key was produced by the same schedule instance you are indexing - cross-schedule lookups should go by name or type, not key."],"exampleFix":"// before\nlet system = systems[key]; // panics on stale/foreign key\n\n// after\nlet Some(system) = systems.get(key) else {\n    // key no longer valid here; refresh keys from the schedule\n    return;\n};","handlingStrategy":"validation","validationCode":"if systems.get(key).is_some() {\n    let system = &systems[key]; // now known-valid\n} else {\n    // key is stale: re-fetch from the owning schedule\n}","typeGuard":"fn system_key_is_live(systems: &Systems, key: SystemKey) -> bool {\n    systems.get(key).is_some()\n}","tryCatchPattern":null,"preventionTips":["Treat SystemKey as schedule-local and non-durable: never cache across rebuilds.","Prefer .get()/get_mut() over the [] operators for key lookups.","Cross-reference systems by name or type, not by key, when data crosses schedule boundaries."],"tags":["bevy","ecs","schedule","panic","slotmap","invalid-key"],"backgroundTag":"stale-handle-lookup","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}