{"record":{"id":"809d5d88298e7c26","repo":"bevyengine/bevy","slug":"invalid-id-0","errorCode":null,"errorMessage":"Invalid id: {0}","messagePattern":"Invalid id: (.+?)","errorType":"exception","errorClass":"SpawnError","httpStatus":null,"severity":"error","filePath":"crates/bevy_ecs/src/entity/mod.rs","lineNumber":1115,"sourceCode":"        self.meta\n            .iter()\n            .filter(|meta| meta.location.is_some())\n            .count() as u32\n    }\n\n    /// Returns true if there are any entity indices currently spawned.\n    /// See the module docs for a more precise explanation of what spawning means.\n    pub fn any_spawned(&self) -> bool {\n        self.meta.iter().any(|meta| meta.location.is_some())\n    }\n}\n\n/// An error that occurs when a specified [`Entity`] can not be spawned.\n#[derive(thiserror::Error, Debug, Clone, Copy, PartialEq, Eq)]\npub enum SpawnError {\n    /// The [`Entity`] to spawn was invalid.\n    /// It probably had the wrong generation or was created erroneously.\n    #[error(\"Invalid id: {0}\")]\n    Invalid(InvalidEntityError),\n    /// The [`Entity`] to spawn was already spawned.\n    #[error(\"The entity can not be spawned as it already has a location.\")]\n    AlreadySpawned,\n}\n\n/// An error that occurs when a specified [`Entity`] does not exist in the entity id space.\n/// See [module](crate::entity) docs for more about entity validity.\n#[derive(thiserror::Error, Debug, Clone, Copy, PartialEq, Eq)]\n#[error(\n    \"The entity with ID {entity} is invalid; its index now has generation {current_generation}.\"\n)]\npub struct InvalidEntityError {\n    /// The entity's ID.\n    pub entity: Entity,\n    /// The generation of the [`EntityIndex`], which did not match the requested entity.\n    pub current_generation: EntityGeneration,\n}","sourceCodeStart":1097,"sourceCodeEnd":1133,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_ecs/src/entity/mod.rs#L1097-L1133","documentation":"thiserror Display message for SpawnError::Invalid: an attempted spawn used an Entity whose id failed validation — typically the wrong generation for a freed index, or an Entity fabricated without the allocator. The wrapped InvalidEntityError supplies the offending id in {0}.","triggerScenarios":"Thrown at crates/bevy_ecs/src/entity/mod.rs:1115 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Obtain Entity ids only from the same World's spawn/reserve APIs","If the id came from an earlier frame, re-fetch it — the entity was likely despawned and its generation advanced","When using reserved entities, finish spawning via the returned Entity command before other use"],"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"}