{"record":{"id":"86c1b6533a30317b","repo":"bevyengine/bevy","slug":"mesh-is-missing-requested-attribute-name-id","errorCode":null,"errorMessage":"Mesh is missing requested attribute: {name} ({id:?}, pipeline type: {pipeline_type:?})","messagePattern":"Mesh is missing requested attribute: (.+?) \\((.+?), pipeline type: (.+?)\\)","errorType":"exception","errorClass":"MissingVertexAttributeError","httpStatus":null,"severity":"error","filePath":"crates/bevy_mesh/src/vertex.rs","lineNumber":163,"sourceCode":"            } else {\n                return Err(MissingVertexAttributeError {\n                    id: attribute_descriptor.id,\n                    name: attribute_descriptor.name,\n                    pipeline_type: None,\n                });\n            }\n        }\n\n        Ok(VertexBufferLayout {\n            array_stride: self.layout.array_stride,\n            step_mode: self.layout.step_mode,\n            attributes,\n        })\n    }\n}\n\n#[derive(Error, Debug)]\n#[error(\"Mesh is missing requested attribute: {name} ({id:?}, pipeline type: {pipeline_type:?})\")]\npub struct MissingVertexAttributeError {\n    pub pipeline_type: Option<&'static str>,\n    id: MeshVertexAttributeId,\n    name: &'static str,\n}\n\npub struct VertexAttributeDescriptor {\n    pub shader_location: u32,\n    pub id: MeshVertexAttributeId,\n    name: &'static str,\n}\n\nimpl VertexAttributeDescriptor {\n    pub const fn new(shader_location: u32, id: MeshVertexAttributeId, name: &'static str) -> Self {\n        Self {\n            shader_location,\n            id,\n            name,","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_mesh/src/vertex.rs#L145-L181","documentation":"MissingVertexAttributeError is returned by MeshVertexBufferLayout::get_layout (crates/bevy_mesh/src/vertex.rs:146) while assembling the GPU VertexBufferLayout for a pipeline. A pipeline declares the vertex attributes its shader reads (as VertexAttributeDescriptors); if any requested attribute id is not present in the mesh's attribute set, layout building fails with this error, naming the attribute, its id, and the pipeline type when known. It is the standard signal that a shader's vertex input contract and the mesh's data disagree.","triggerScenarios":"Specializing or building a render pipeline whose layout requests attributes such as ATTRIBUTE_NORMAL, ATTRIBUTE_UV_0, ATTRIBUTE_TANGENT or ATTRIBUTE_JOINT_INDEX via mesh.get_vertex_buffer_layout()/MeshVertexBufferLayout::get_layout, while the mesh never inserted one of them.","commonSituations":"A custom Material/shader that samples UVs applied to a mesh generated without UVs; a pipeline that requires NORMALs on a raw TriangleList mesh built from just positions; skinned-shader pipelines run against static meshes; mixing procedurally-built meshes with assets authored in another tool.","solutions":["Add the missing attribute to the mesh: generate it with mesh.compute_normals() / compute_tangents(), or insert Mesh::ATTRIBUTE_UV_0 with matching vertex count","If the shader does not truly need the attribute, remove it from the pipeline's layout descriptors so get_layout stops requesting it","Select a different shader/pipeline variant for attribute-poor meshes (branch on mesh_vertex_buffer_layout.contains(...))","Read the error's name/id to identify exactly which attribute the pipeline demanded"],"exampleFix":"// before: shader pipeline requires UVs the mesh does not have\nlet layout = mesh.get_vertex_buffer_layout(&[\n    Mesh::ATTRIBUTE_POSITION.at_shader_location(0),\n    Mesh::ATTRIBUTE_UV_0.at_shader_location(1),\n])?; // Err(MissingVertexAttributeError { name: \"UV_0\" .. })\n\n// after: supply UVs (or drop location 1 from the layout)\nlet uvs: Vec<[f32; 2]> = (0..vertex_count).map(|_| [0.0, 0.0]).collect();\nmesh.insert_attribute(Mesh::ATTRIBUTE_UV_0, uvs);","handlingStrategy":"validation","validationCode":"// Ensure the mesh provides every attribute the pipeline will request\nlet layout = mesh.get_mesh_vertex_buffer_layout(); // the mesh's attribute set\nlet required = [Mesh::ATTRIBUTE_POSITION, Mesh::ATTRIBUTE_NORMAL, Mesh::ATTRIBUTE_UV_0];\nlet missing: Vec<_> = required.iter().filter(|a| !layout.contains(**a)).collect();\nif missing.is_empty() {\n    let vbl = layout.get_layout(&[\n        Mesh::ATTRIBUTE_POSITION.at_shader_location(0),\n        Mesh::ATTRIBUTE_NORMAL.at_shader_location(1),\n        Mesh::ATTRIBUTE_UV_0.at_shader_location(2),\n    ])?;\n}","typeGuard":"fn mesh_has_attribute(mesh: &Mesh, attribute: MeshVertexAttribute) -> bool {\n    mesh.attribute(attribute).is_some()\n}","tryCatchPattern":"match mesh_layout.get_layout(&descriptors) {\n    Ok(vbl) => { /* create pipeline */ }\n    Err(e @ MissingVertexAttributeError { name, .. }) => {\n        error!(\"pipeline needs attribute {name} that the mesh lacks: {e}\");\n        // fall back to a position-only pipeline variant or generate the attribute\n    }\n}","preventionTips":["List the shader's vertex inputs in one place and assert the mesh satisfies them during pipeline specialization","Generate derived attributes at load time: compute_normals(), compute_tangents(), or placeholder UVs","Branch on mesh_vertex_buffer_layout.contains(...) to pick a pipeline variant that matches the mesh's data"],"tags":["bevy","mesh","render-pipeline","vertex-layout","attributes"],"backgroundTag":"missing-mesh-attribute","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"}