bevyengine/bevy · error · InvalidGenerationError
AssetIndex {index:?} has an invalid generation. The current
Error message
AssetIndex {index:?} has an invalid generation. The current generation is: '{current_generation}'. What it means
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.
Source
Thrown at crates/bevy_asset/src/assets.rs:735
}
}
}
if let Some((key, value)) = self.hash_map.next() {
let id = AssetId::Uuid { uuid: *key };
self.queued_events.push(AssetEvent::Modified { id });
Some((id, value))
} else {
None
}
}
}
/// An error returned when an [`AssetIndex`] has an invalid generation.
#[derive(Error, Debug, PartialEq, Eq)]
pub enum InvalidGenerationError {
/// The generation of this [`AssetIndex`] does not match the current generation.
/// That means its index entry has been replaced.
#[error("AssetIndex {index:?} has an invalid generation. The current generation is: '{current_generation}'.")]
Occupied {
/// The index being looked up.
index: AssetIndex,
/// The generation currently at that index.
current_generation: u32,
},
/// This index entry has been removed.
#[error("AssetIndex {index:?} has been removed")]
Removed { index: AssetIndex },
}
#[cfg(test)]
mod test {
use crate::tests::create_app;
use crate::{Asset, AssetApp, AssetEvent, AssetIndex, Assets};
use bevy_ecs::prelude::Messages;
use bevy_reflect::TypePath;
View on GitHub (pinned to 396ca72708)
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/bevy_asset/src/assets.rs:735 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of bevyengine/bevy@396ca72708 (2026-08-20).
Data as JSON: /api/errors/21a884924d7846a3.
Report an issue: GitHub.