{"record":{"id":"21a884924d7846a3","repo":"bevyengine/bevy","slug":"assetindex-index-has-an-invalid-generation-th","errorCode":null,"errorMessage":"AssetIndex {index:?} has an invalid generation. The current generation is: '{current_generation}'.","messagePattern":"AssetIndex (.+?) has an invalid generation\\. The current generation is: '(.+?)'\\.","errorType":"exception","errorClass":"InvalidGenerationError","httpStatus":null,"severity":"error","filePath":"crates/bevy_asset/src/assets.rs","lineNumber":735,"sourceCode":"                }\n            }\n        }\n        if let Some((key, value)) = self.hash_map.next() {\n            let id = AssetId::Uuid { uuid: *key };\n            self.queued_events.push(AssetEvent::Modified { id });\n            Some((id, value))\n        } else {\n            None\n        }\n    }\n}\n\n/// An error returned when an [`AssetIndex`] has an invalid generation.\n#[derive(Error, Debug, PartialEq, Eq)]\npub enum InvalidGenerationError {\n    /// The generation of this [`AssetIndex`] does not match the current generation.\n    /// That means its index entry has been replaced.\n    #[error(\"AssetIndex {index:?} has an invalid generation. The current generation is: '{current_generation}'.\")]\n    Occupied {\n        /// The index being looked up.\n        index: AssetIndex,\n        /// The generation currently at that index.\n        current_generation: u32,\n    },\n    /// This index entry has been removed.\n    #[error(\"AssetIndex {index:?} has been removed\")]\n    Removed { index: AssetIndex },\n}\n\n#[cfg(test)]\nmod test {\n    use crate::tests::create_app;\n    use crate::{Asset, AssetApp, AssetEvent, AssetIndex, Assets};\n    use bevy_ecs::prelude::Messages;\n    use bevy_reflect::TypePath;\n","sourceCodeStart":717,"sourceCodeEnd":753,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_asset/src/assets.rs#L717-L753","documentation":"InvalidGenerationError::Occupied: an AssetIndex lookup found an entry at that index but its generation does not match the current generation stored for the index. The entry at the slot has been replaced (a new asset took over the index), so the old handle/index refers to a stale slot.","triggerScenarios":"Thrown at crates/bevy_asset/src/assets.rs:735 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Treat the stale index as invalid and re-acquire the asset through a fresh handle","Avoid holding on to AssetIndex values across asset removal/reinsertion cycles","If you control insertion, insert with the returned new index rather than reusing an old one"],"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-14T00:17:10.932Z"}