bevyengine/bevy · error

expected bundle `{}` to be a named struct or tuple

Error message

expected bundle `{}` to be a named struct or tuple

What it means

Panic in ReflectBundleFns::apply: the reflected bundle value being applied is not represented as a named struct or tuple, so the apply loop over its fields has no supported layout to read. Distinct from the insert-time variant: this fires while applying to an entity that already has components.

Source

Thrown at crates/bevy_ecs/src/reflect/bundle.rs:218

                                apply_or_insert_field_mapped(
                                    entity,
                                    field,
                                    registry,
                                    mapper,
                                    relationship_hook_mode,
                                );
                            });
                        }
                        ReflectRef::Tuple(bundle) => bundle.iter_fields().for_each(|field| {
                            apply_or_insert_field_mapped(
                                entity,
                                field,
                                registry,
                                mapper,
                                relationship_hook_mode,
                            );
                        }),
                        _ => panic!(
                            "expected bundle `{}` to be a named struct or tuple",
                            // FIXME: once we have unique reflect, use `TypePath`.
                            DebugName::type_name::<B>(),
                        ),
                    }
                }
            },
            remove: |entity| {
                entity.remove::<B>();
            },
            take: |entity| {
                entity
                    .take::<B>()
                    .map(|bundle| Box::new(bundle).into_reflect())
            },
        })
    }
}

View on GitHub (pinned to 396ca72708)

Solutions

  1. Apply a reflected value created from the same bundle type (Struct/Tuple representation)
  2. Convert dynamic reflect data through ReflectDefault/from_reflect into the bundle type first
  3. Validate reflected_bundle.reflect_ref() shape before calling apply
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at crates/bevy_ecs/src/reflect/bundle.rs:218 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/bb9c323e7579a92a. Report an issue: GitHub.