bevyengine/bevy · error · ApplyError
attempted to apply `{from_kind}` to `{to_kind}`
Error message
attempted to apply `{from_kind}` to `{to_kind}` What it means
ApplyError::MismatchedKinds — PartialReflect::try_apply was asked to apply a value of one ReflectKind (e.g. struct) onto a destination of another kind (e.g. enum), which is impossible. Payloads: from_kind and to_kind ReflectKinds. Apply values of matching kinds.
Source
Thrown at crates/bevy_reflect/src/reflect.rs:23
ReflectOwned, ReflectRef, TypeInfo, TypePath, Typed,
};
use alloc::borrow::Cow;
use alloc::boxed::Box;
use alloc::string::ToString;
use core::{
any::{Any, TypeId},
cmp::Ordering,
fmt::Debug,
};
use thiserror::Error;
use crate::utility::NonGenericTypeInfoCell;
/// A enumeration of all error outcomes that might happen when running [`try_apply`](PartialReflect::try_apply).
#[derive(Error, Debug)]
pub enum ApplyError {
#[error("attempted to apply `{from_kind}` to `{to_kind}`")]
/// Attempted to apply the wrong [kind](ReflectKind) to a type, e.g. a struct to an enum.
MismatchedKinds {
/// Kind of the value we attempted to apply.
from_kind: ReflectKind,
/// Kind of the type we attempted to apply the value to.
to_kind: ReflectKind,
},
#[error("enum variant `{variant_name}` doesn't have a field named `{field_name}`")]
/// Enum variant that we tried to apply to was missing a field.
MissingEnumField {
/// Name of the enum variant.
variant_name: Box<str>,
/// Name of the missing field.
field_name: Box<str>,
},
#[error("`{from_type}` is not `{to_type}`")]View on GitHub (pinned to 396ca72708)
Solutions
- Apply a value of the same reflected kind as the target
- Convert the source to the target's kind before applying
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at crates/bevy_reflect/src/reflect.rs:23 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/5bf2b40dc4845d2b.
Report an issue: GitHub.