{"record":{"id":"16979d41040f0fd2","repo":"bevyengine/bevy","slug":"system-set-with-key-does-not-exist-in-the-sch","errorCode":null,"errorMessage":"System set with key {:?} does not exist in the schedule","messagePattern":"System set 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":899,"sourceCode":"                let before = dependency.edges_directed(NodeId::Set(key), Incoming);\n                let after = dependency.edges_directed(NodeId::Set(key), Outgoing);\n                let relations = before.count() + after.count() + ambiguous_with.count();\n                if instances > 1 && relations > 0 {\n                    return Err(SystemTypeSetAmbiguityError(key));\n                }\n            }\n        }\n        Ok(())\n    }\n}\n\nimpl Index<SystemSetKey> for SystemSets {\n    type Output = dyn SystemSet;\n\n    #[track_caller]\n    fn index(&self, key: SystemSetKey) -> &Self::Output {\n        self.get(key).unwrap_or_else(|| {\n            panic!(\n                \"System set with key {:?} does not exist in the schedule\",\n                key\n            )\n        })\n    }\n}\n\n/// Error returned when calling [`SystemSets::check_type_set_ambiguity`].\n#[derive(Error, Debug)]\n#[error(\"Tried to order against `{0:?}` in a schedule that has more than one `{0:?}` instance. `{0:?}` is a `SystemTypeSet` and cannot be used for ordering if ambiguous. Use a different set without this restriction.\")]\npub struct SystemTypeSetAmbiguityError(pub SystemSetKey);\n\n#[cfg(test)]\nmod tests {\n    use alloc::{boxed::Box, vec};\n\n    use crate::{\n        prelude::SystemSet,","sourceCodeStart":881,"sourceCodeEnd":917,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_ecs/src/schedule/node.rs#L881-L917","documentation":"Panics when the SystemSets container is indexed with a SystemSetKey that is not live in the schedule: the set was removed, the key came from a different schedule, or it was otherwise stale. It comes from the Index<SystemSetKey> impl used by sets[key].","triggerScenarios":"Indexing sets by a key captured before the set was removed; using keys from another schedule's SystemSets map; editor/tooling code caching SystemSetKeys across schedule rebuilds.","commonSituations":"Debug UIs listing sets by cached keys while configuration changes; dynamic set removal (configure_sets changed between frames); refactors that move sets between schedules.","solutions":["Use sets.get(key) and handle None instead of indexing.","Re-query set keys from the owning schedule after any configuration change.","Identify sets by InternedSystemSet/name rather than key for anything persisted across frames."],"exampleFix":"// before\nlet set = sets[key]; // panics if the key is stale\n\n// after\nlet Some(set) = sets.get(key) else {\n    return; // refresh the key from the schedule before use\n};","handlingStrategy":"validation","validationCode":"if let Some(set) = sets.get(key) {\n    // use the set\n} else {\n    // stale key: re-query from the owning schedule\n}","typeGuard":"fn set_key_is_live(sets: &SystemSets, key: SystemSetKey) -> bool {\n    sets.get(key).is_some()\n}","tryCatchPattern":null,"preventionTips":["Re-query SystemSetKeys after any configure_sets change.","Identify sets by name/InternedSystemSet for anything persisted across frames.","Use get() rather than [] indexing in tooling."],"tags":["bevy","ecs","schedule","panic","system-set","invalid-key"],"backgroundTag":"stale-handle-lookup","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}