From 12da4e482a8c8a3486204138ee4172aa828d42a4 Mon Sep 17 00:00:00 2001 From: Zeenobit Date: Mon, 7 Jul 2025 16:04:59 -0400 Subject: [PATCH] Add parent ID to the `B0004` log message (#19980) # Objective Minor CL to add parent entity ID to the B0004 error message to improve debugging. --- crates/bevy_ecs/src/hierarchy.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/crates/bevy_ecs/src/hierarchy.rs b/crates/bevy_ecs/src/hierarchy.rs index fe9bf571c9..d325d5756c 100644 --- a/crates/bevy_ecs/src/hierarchy.rs +++ b/crates/bevy_ecs/src/hierarchy.rs @@ -455,15 +455,13 @@ pub fn validate_parent_has_component( let Some(child_of) = entity_ref.get::() else { return; }; - if !world - .get_entity(child_of.parent()) - .is_ok_and(|e| e.contains::()) - { + let parent = child_of.parent(); + if !world.get_entity(parent).is_ok_and(|e| e.contains::()) { // TODO: print name here once Name lives in bevy_ecs let name: Option = None; let debug_name = DebugName::type_name::(); warn!( - "warning[B0004]: {}{name} with the {ty_name} component has a parent without {ty_name}.\n\ + "warning[B0004]: {}{name} with the {ty_name} component has a parent ({parent}) without {ty_name}.\n\ This will cause inconsistent behaviors! See: https://bevy.org/learn/errors/b0004", caller.map(|c| format!("{c}: ")).unwrap_or_default(), ty_name = debug_name.shortname(),