bevyengine/bevy · error
FromReflect::from_reflect failed when called on type `{}` wi
Error message
FromReflect::from_reflect failed when called on type `{}` with this value: {value:?} What it means
Panic inside the ReflectSerialize/FromReflect type-data closure: downcasting a value to the registered type T failed during serialization-related FromReflect conversion, so the value's actual type differs from the registered one.
Source
Thrown at crates/bevy_reflect/src/type_registry.rs:854
/// A struct used to serialize reflected instances of a type.
///
/// A `ReflectSerialize` for type `T` can be obtained via
/// [`CreateTypeData::create_type_data`].
#[derive(Clone)]
pub struct ReflectSerialize {
get_serializable: fn(value: &dyn Reflect) -> Serializable,
}
impl<T: TypePath + FromReflect + erased_serde::Serialize> CreateTypeData<T> for ReflectSerialize {
fn create_type_data(_input: ()) -> Self {
ReflectSerialize {
get_serializable: |value| {
value
.downcast_ref::<T>()
.map(|value| Serializable::Borrowed(value))
.or_else(|| T::from_reflect(value.as_partial_reflect()).map(|value| Serializable::Owned(Box::new(value))))
.unwrap_or_else(|| {
panic!(
"FromReflect::from_reflect failed when called on type `{}` with this value: {value:?}",
T::type_path(),
);
})
},
}
}
}
impl ReflectSerialize {
/// Turn the value into a serializable representation
pub fn get_serializable<'a>(&self, value: &'a dyn Reflect) -> Serializable<'a> {
(self.get_serializable)(value)
}
/// Serializes a reflected value.
pub fn serialize<S>(&self, value: &dyn Reflect, serializer: S) -> Result<S::Ok, S::Error>
whereView on GitHub (pinned to 396ca72708)
Solutions
- Ensure values passed match the registered type
- Fix type registration so the same type is registered and used
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at crates/bevy_reflect/src/type_registry.rs:854 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/119f62376d28d42b.
Report an issue: GitHub.