bevyengine/bevy · error · UntypedAssetIdConversionError

This UntypedAssetId is for {found:?} and cannot be converted

Error message

This UntypedAssetId is for {found:?} and cannot be converted into an AssetId<{expected:?}>

What it means

UntypedAssetIdConversionError variant: converting an UntypedAssetId into an AssetId<A> failed because the untyped id's stored type is `found`, not the requested `expected` type A. Same class of mismatch as the handle conversion error, but for ids.

Source

Thrown at crates/bevy_asset/src/id.rs:474

impl From<ErasedAssetIndex> for UntypedAssetId {
    fn from(value: ErasedAssetIndex) -> Self {
        Self::Index {
            type_id: value.type_id,
            index: value.index,
        }
    }
}

#[derive(Error, Debug)]
#[error("Attempted to create a TypedAssetIndex from a Uuid")]
pub(crate) struct UuidNotSupportedError;

/// Errors preventing the conversion of to/from an [`UntypedAssetId`] and an [`AssetId`].
#[derive(Error, Debug, PartialEq, Clone)]
#[non_exhaustive]
pub enum UntypedAssetIdConversionError {
    /// Caused when trying to convert an [`UntypedAssetId`] into an [`AssetId`] of the wrong type.
    #[error("This UntypedAssetId is for {found:?} and cannot be converted into an AssetId<{expected:?}>")]
    TypeIdMismatch {
        /// The [`TypeId`] of the asset that we are trying to convert to.
        expected: TypeId,
        /// The [`TypeId`] of the asset that we are trying to convert from.
        found: TypeId,
    },
}

#[cfg(test)]
mod tests {
    use super::*;

    type TestAsset = ();

    const UUID_1: Uuid = Uuid::from_u128(123);
    const UUID_2: Uuid = Uuid::from_u128(456);

    /// Simple utility to directly hash a value using a fixed hasher

View on GitHub (pinned to 396ca72708)

Solutions

  1. Request the AssetId for the actual asset type stored in the UntypedAssetId
  2. Check UntypedAssetId::type_id() before converting when the type is not statically known
  3. Use try_typed() and react to the returned error rather than assuming the type
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at crates/bevy_asset/src/id.rs:474 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/b4c6b22b177c21f4. Report an issue: GitHub.