{"record":{"id":"d24cde8946a8a747","repo":"bevyengine/bevy","slug":"malformed-vertex-attribute-data","errorCode":null,"errorMessage":"Malformed vertex attribute data","messagePattern":"Malformed vertex attribute data","errorType":"exception","errorClass":"AccessFailed","httpStatus":null,"severity":"error","filePath":"crates/bevy_gltf/src/vertex_attributes.rs","lineNumber":35,"sourceCode":"        self,\n        value: T,\n        normalized_ctor: impl Fn(T) -> U,\n        unnormalized_ctor: impl Fn(T) -> U,\n    ) -> U {\n        if self.0 {\n            normalized_ctor(value)\n        } else {\n            unnormalized_ctor(value)\n        }\n    }\n}\n\n/// An error that occurs when accessing buffer data\n#[derive(Error, Debug)]\npub enum AccessFailed {\n    /// Accessing the data failed because of an issue like a mismatch in stride,\n    /// or a buffer view slice failing.\n    #[error(\"Malformed vertex attribute data\")]\n    MalformedData,\n    /// The format supplied is unsupported for this operation.\n    #[error(\"Unsupported vertex attribute format\")]\n    UnsupportedFormat,\n}\n\n/// Helper for reading buffer data\nstruct BufferAccessor<'a> {\n    accessor: gltf::Accessor<'a>,\n    buffer_data: &'a Vec<Vec<u8>>,\n    normalization: Normalization,\n}\n\nimpl<'a> BufferAccessor<'a> {\n    /// Creates an iterator over the elements in this accessor\n    fn iter<T: gltf::accessor::Item>(self) -> Result<gltf::accessor::Iter<'a, T>, AccessFailed> {\n        gltf::accessor::Iter::new(self.accessor, |buffer: gltf::Buffer| {\n            self.buffer_data.get(buffer.index()).map(Vec::as_slice)","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_gltf/src/vertex_attributes.rs#L17-L53","documentation":"AccessFailed::MalformedData is produced in BufferAccessor::iter (crates/bevy_gltf/src/vertex_attributes.rs:51-56) when gltf::accessor::Iter::new returns None: the accessor cannot be decoded against the loaded buffers. Per the doc comment this covers stride mismatches and buffer-view slicing failures — e.g. accessor byteOffset/byteLength exceeding its bufferView, a view out of bounds of its buffer, or a stride invalid for the data type. It surfaces to callers as ConvertAttributeError::AccessFailed(MalformedData, accessor_index) ('Malformed vertex attribute data in accessor N').","triggerScenarios":"Any mesh attribute accessor whose declared offsets/lengths/strides disagree with the actual buffer bytes — e.g. after manual JSON edits, corrupt downloads, or exporters writing byteLength wrong; sparse/odd strides not representable by the gltf iterator.","commonSituations":"Hand-tuned buffer optimizations, files truncated then 'repaired', quantization pipelines writing invalid accessor metadata.","solutions":["Run gltf-validator — it reports out-of-bounds accessors/bufferViews precisely.","Re-export the model from the source DCC.","If you generate glTF yourself, recompute byteOffset/byteLength/stride so every accessor fits inside its bufferView and every view inside its buffer."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"fn accessors_fit(doc: &gltf::Document, buffers: &[Vec<u8>]) -> bool {\n    doc.accessors().all(|a| {\n        a.view().map(|v| {\n            let buf = buffers.get(v.buffer().index()).map(|b| b.len()).unwrap_or(0);\n            let end = v.offset() + v.length();\n            let acc_end = a.offset().unwrap_or(0) + a.size();\n            end <= buf && acc_end <= v.length()\n        }).unwrap_or(false)\n    })\n}","typeGuard":null,"tryCatchPattern":"match err {\n    ConvertAttributeError::AccessFailed(AccessFailed::MalformedData, idx) => {\n        error!(\"accessor {idx} does not decode (offset/length/stride vs buffer); re-export or validate the file\");\n    }\n    other => return Err(other.into()),\n}","preventionTips":["Make gltf-validator part of the asset import pipeline.","Never hand-edit accessor byteOffset/byteLength without recomputing bounds.","Detect truncated downloads by comparing file size with source manifest."],"tags":["gltf","accessor","buffer-view","vertex-attributes","bevy"],"backgroundTag":"gltf-malformed-accessor","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}