{"record":{"id":"0e739799262e5d95","repo":"FyroxEngine/Fyrox","slug":"resource-type-mismatch-expected-expected-foun","errorCode":null,"errorMessage":"Resource type mismatch. Expected: {expected}. Found: {type_uuid}","messagePattern":"Resource type mismatch\\. Expected: (.+?)\\. Found: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"fyrox-resource/src/lib.rs","lineNumber":494,"sourceCode":"impl<T> From<Uuid> for Resource<T>\nwhere\n    T: TypedResourceData,\n{\n    fn from(uuid: Uuid) -> Self {\n        UntypedResource::from(uuid).into()\n    }\n}\n\nimpl<T> From<UntypedResource> for Resource<T>\nwhere\n    T: TypedResourceData,\n{\n    #[inline]\n    fn from(untyped: UntypedResource) -> Self {\n        if let Some(type_uuid) = untyped.type_uuid() {\n            let expected = <T as Reflect>::type_info().type_uuid;\n            if type_uuid != expected {\n                panic!(\"Resource type mismatch. Expected: {expected}. Found: {type_uuid}\");\n            }\n        }\n        Self {\n            untyped,\n            phantom: Default::default(),\n        }\n    }\n}\n\n#[allow(clippy::from_over_into)]\nimpl<T> Into<UntypedResource> for Resource<T>\nwhere\n    T: TypedResourceData,\n{\n    #[inline]\n    fn into(self) -> UntypedResource {\n        self.untyped\n    }","sourceCodeStart":476,"sourceCodeEnd":512,"githubUrl":"https://github.com/FyroxEngine/Fyrox/blob/76c91aad8eca488ce527b1af707be8b3b24ad72d/fyrox-resource/src/lib.rs#L476-L512","documentation":"The From<UntypedResource> impl for Resource<T> converts an untyped resource into a typed one, but panics if the resource's actual type UUID differs from the expected T::type_uuid. This is a hard type check: the library prefers failing fast over silently wrapping a resource of the wrong type.","triggerScenarios":"Calling .into()/Resource::<T>::from(untyped) where untyped holds e.g. a Model while T is Texture; passing a resource loaded from a file whose extension/format does not match T.","commonSituations":"requesting resources generically then casting without checking; data files renamed/misconfigured so the wrong loader produced the resource; API changes where the expected resource type changed.","solutions":["Check untyped.resource_state/type_uuid before conversion, or use try_cast / cast::<T>() which returns Option instead of panicking.","Request the resource with the correct concrete type via resource_manager.request::<Texture>(path).","Fix the path/extension so the resource loads as the intended type."],"exampleFix":"// before\nlet texture: TextureResource = model_untyped.into(); // panics on mismatch\n// after\nif let Some(texture) = model_untyped.cast::<Texture>() {\n    // use texture\n}","handlingStrategy":"type-guard","validationCode":"let ok = untyped.type_uuid() == Some(<Texture as Reflect>::type_info().type_uuid);","typeGuard":"fn is_same_type<T: Reflect>(untyped: &UntypedResource) -> bool {\n    untyped.type_uuid() == Some(<T as Reflect>::type_info().type_uuid)\n}","tryCatchPattern":null,"preventionTips":["Always use UntypedResource::cast::<T>() (returns Option) instead of From/into for conversions.","Request resources as concrete types via resource_manager.request::<T>() rather than untyped + cast.","Verify asset extensions map to the intended loader/type when setting up paths."],"tags":["panic","type-mismatch","resources"],"backgroundTag":"type-mismatch","analyzedSha":"76c91aad8eca488ce527b1af707be8b3b24ad72d","analyzedAt":"2026-09-10T16:04:01.633Z","contentChangedAt":"2026-09-10T16:04:01.633Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}