{"record":{"id":"6a4d3ec43bfb3d02","repo":"bevyengine/bevy","slug":"attribute-0-has-unexpected-format-1","errorCode":null,"errorMessage":"Attribute \"{0}\" has unexpected format {1:?}","messagePattern":"Attribute \"(.+?)\" has unexpected format (.+?)","errorType":"exception","errorClass":"MeshAttributeError","httpStatus":null,"severity":"error","filePath":"crates/bevy_mesh/src/skinning.rs","lineNumber":416,"sourceCode":"\n            if joint_weight > 0.0 {\n                return Some(Influence {\n                    vertex_index: self.vertex_index,\n                    joint_index: JointIndex(joint_index),\n                    joint_weight,\n                });\n            }\n        }\n    }\n}\n\n/// Generic error for when a mesh was expected to have a certain attribute with\n/// a certain format.\n#[derive(Copy, Clone, PartialEq, Debug, Error)]\npub enum MeshAttributeError {\n    #[error(\"Missing attribute \\\"{0}\\\"\")]\n    MissingAttribute(&'static str),\n    #[error(\"Attribute \\\"{0}\\\" has unexpected format {1:?}\")]\n    UnexpectedFormat(&'static str, VertexFormat),\n}\n\n// Implements a function that returns a mesh attribute's data or `MeshAttributeError`.\n//\n// ```\n// impl_expect_attribute!(expect_attribute_float32x3, Float32x3, [f32; 3]);\n//\n// let positions: Vec<[f32; 3]> = expect_attribute_float32x3(mesh, Mesh::ATTRIBUTE_POSITION)?;\n// ```\nmacro_rules! impl_expect_attribute {\n    ($name:ident, $value_type:ident, $output_type:ty) => {\n        fn $name<'a>(\n            mesh: &'a Mesh,\n            attribute: MeshVertexAttribute,\n        ) -> Result<&'a Vec<$output_type>, MeshAttributeError> {\n            match mesh.attribute(attribute) {\n                Some(VertexAttributeValues::$value_type(v)) => Ok(v),","sourceCodeStart":398,"sourceCodeEnd":434,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_mesh/src/skinning.rs#L398-L434","documentation":"MeshAttributeError::UnexpectedFormat is returned when a mesh attribute exists but its VertexFormat differs from the one the API requires. The expect_attribute_* helpers in bevy_mesh::skinning accept exactly one variant: POSITION must be Float32x3, JOINT_INDEX must be Uint16x4, and JOINT_WEIGHT must be Float32x4. Any other variant for those attributes produces this error, with the offending format included in the message.","triggerScenarios":"Calling SkinnedMeshBounds::from_mesh (or InfluenceIterator::new) on a mesh where, for example, JOINT_INDEX is stored as Uint32x4/Uint8x4 instead of Uint16x4, JOINT_WEIGHT is not Float32x4, or POSITION is not Float32x3 (e.g. half-float or Float32x2).","commonSituations":"Importers or packers that widen joint indices to u32 for precision; custom compressed vertex formats; hand-building a skinned mesh with the wrong Rust type for weights (e.g. [f32; 3] or u16 weights); meshes converted for vertex-compression pipelines.","solutions":["Re-insert the attribute in the exact required format: convert JOINT_INDEX to Vec<[u16; 4]> and JOINT_WEIGHT to Vec<[f32; 4]> before inserting","If joint indices exceed u16 range, remap/reindex joints so they fit u16, then store Uint16x4","Read the error's format field to see the actual variant and write a targeted conversion"],"exampleFix":"// before: joint indices stored as u32\nmesh.insert_attribute(Mesh::ATTRIBUTE_JOINT_INDEX, joint_indices_u32x4);\nSkinnedMeshBounds::from_mesh(&mesh)?; // Err(UnexpectedFormat(\"JOINT_INDEX\", Uint32x4))\n\n// after: convert to the expected Uint16x4\nlet joint_indices_u16x4: Vec<[u16; 4]> = joint_indices_u32x4\n    .iter()\n    .map(|j| [j[0] as u16, j[1] as u16, j[2] as u16, j[3] as u16])\n    .collect();\nmesh.insert_attribute(Mesh::ATTRIBUTE_JOINT_INDEX, joint_indices_u16x4);\nSkinnedMeshBounds::from_mesh(&mesh)?; // Ok(..)","handlingStrategy":"type-guard","validationCode":"// Confirm the exact formats skinning requires before calling from_mesh\nfn skin_attributes_well_formed(mesh: &Mesh) -> bool {\n    matches!(mesh.attribute(Mesh::ATTRIBUTE_POSITION), Some(VertexAttributeValues::Float32x3(_)))\n        && matches!(mesh.attribute(Mesh::ATTRIBUTE_JOINT_INDEX), Some(VertexAttributeValues::Uint16x4(_)))\n        && matches!(mesh.attribute(Mesh::ATTRIBUTE_JOINT_WEIGHT), Some(VertexAttributeValues::Float32x4(_)))\n}","typeGuard":"fn attribute_is_format(mesh: &Mesh, attr: MeshVertexAttribute, fmt: VertexFormat) -> bool {\n    mesh.attribute(attr).is_some_and(|v| VertexFormat::from(v) == fmt)\n}","tryCatchPattern":"match SkinnedMeshBounds::from_mesh(&mesh) {\n    Ok(bounds) => { /* use */ }\n    Err(SkinnedMeshBoundsError::MeshAttributeError(\n        MeshAttributeError::UnexpectedFormat(name, fmt),\n    )) => {\n        warn!(\"attribute {name} has format {fmt:?}; re-export the mesh with the standard skin formats\");\n    }\n    Err(other) => warn!(\"skinning bounds failed: {other:?}\"),\n}","preventionTips":["Standardize on the canonical skin formats: POSITION Float32x3, JOINT_INDEX Uint16x4, JOINT_WEIGHT Float32x4","Write importer checks that re-type u32 joint indices to u16 before insertion","Add a debug_assert in asset loading that all three attributes match the expected variants"],"tags":["bevy","mesh","skinning","vertex-format","attributes"],"backgroundTag":"vertex-attribute-format-mismatch","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}