{"record":{"id":"5f083cc966393d4b","repo":"bevyengine/bevy","slug":"entity-not-yet-spawned-0-note-that-interacting","errorCode":null,"errorMessage":"Entity not yet spawned: {0}\nNote that interacting with a not-yet-spawned entity is the most common cause of this error but there are others","messagePattern":"Entity not yet spawned: (.+?)\nNote that interacting with a not-yet-spawned entity is the most common cause of this error but there are others","errorType":"exception","errorClass":"EntityNotSpawnedError","httpStatus":null,"severity":"error","filePath":"crates/bevy_ecs/src/entity/mod.rs","lineNumber":1166,"sourceCode":"        match self.location.into_option() {\n            Some(location) => write!(f, \"The entity with ID {entity} is not spawned; its index was last despawned by {location}.\"),\n            None => write!(\n                f,\n                \"The entity with ID {entity} is not spawned; enable `track_location` feature for more details.\"\n            ),\n        }\n    }\n}\n\n/// An error that occurs when a specified [`Entity`] is expected to be valid and spawned but is not.\n/// Represents an error of either [`InvalidEntityError`] (when the entity is invalid) or [`EntityValidButNotSpawnedError`] (when the [`EntityGeneration`] is correct but the [`EntityIndex`] is not spawned).\n#[derive(thiserror::Error, Copy, Clone, Debug, Eq, PartialEq)]\npub enum EntityNotSpawnedError {\n    /// The entity was invalid.\n    #[error(\"Entity despawned: {0}\\nNote that interacting with a despawned entity is the most common cause of this error but there are others\")]\n    Invalid(#[from] InvalidEntityError),\n    /// The entity was valid but was not spawned.\n    #[error(\"Entity not yet spawned: {0}\\nNote that interacting with a not-yet-spawned entity is the most common cause of this error but there are others\")]\n    ValidButNotSpawned(#[from] EntityValidButNotSpawnedError),\n}\n\nimpl EntityNotSpawnedError {\n    /// The entity that did not exist or was not spawned.\n    pub fn entity(&self) -> Entity {\n        match self {\n            EntityNotSpawnedError::Invalid(err) => err.entity,\n            EntityNotSpawnedError::ValidButNotSpawned(err) => err.entity,\n        }\n    }\n}\n\n#[derive(Copy, Clone, Debug)]\nstruct EntityMeta {\n    /// The current [`EntityGeneration`] of the [`EntityIndex`].\n    generation: EntityGeneration,\n    /// The current location of the [`EntityIndex`].","sourceCodeStart":1148,"sourceCodeEnd":1184,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_ecs/src/entity/mod.rs#L1148-L1184","documentation":"Label message for the not-yet-spawned flavor of entity errors: the id is reserved/valid but its index has never been given a location in this World (e.g. an Entity obtained from reserve_entity or commands before the spawn is flushed). The note warns that any interaction with such an unspawned index, not only spawn misuse, produces this error.","triggerScenarios":"Thrown at crates/bevy_ecs/src/entity/mod.rs:1166 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure spawn commands are flushed (or use world.flush_commands) before touching reserved entities","Pass reserved Entity ids only where spawning will complete, such as spawn_with commands","Re-query the entity after the frame's command flush to confirm it is live"],"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-14T05:17:10.506Z"}