{"record":{"id":"f61f654f1d017ef3","repo":"bevyengine/bevy","slug":"data-ranges-have-no-binding-resource","errorCode":null,"errorMessage":"Data ranges have no binding resource","messagePattern":"Data ranges have no binding resource","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/bevy_render/src/render_resource/bind_group.rs","lineNumber":871,"sourceCode":"            UnpreparedBindingResource::Sampler(_, sampler) => BindingResource::Sampler(sampler),\n            UnpreparedBindingResource::ShaderBuffer(shader_buffer) => {\n                // Fetch the raw buffer from the\n                // `shader_buffer_assets`. If it's not there,\n                // use the fallback buffer.\n                match shader_buffer_assets.get(shader_buffer.id()) {\n                    Some(shader_buffer) => BindingResource::Buffer(BufferBinding {\n                        buffer: &shader_buffer.buffer,\n                        offset: 0,\n                        size: None,\n                    }),\n                    None => BindingResource::Buffer(BufferBinding {\n                        buffer: fallback_buffer,\n                        offset: 0,\n                        size: None,\n                    }),\n                }\n            }\n            UnpreparedBindingResource::Data(_) => panic!(\"Data ranges have no binding resource\"),\n        }\n    }\n}\n\n/// Converts a value to a [`ShaderType`] for use in a bind group.\n///\n/// This is automatically implemented for references that implement [`Into`].\n/// Generally normal [`Into`] / [`From`] impls should be preferred, but\n/// sometimes additional runtime metadata is required.\n/// This exists largely to make some [`AsBindGroup`] use cases easier.\npub trait AsBindGroupShaderType<T: ShaderType> {\n    /// Return the `T` [`ShaderType`] for `self`. When used in [`AsBindGroup`]\n    /// derives, it is safe to assume that all images in `self` exist.\n    fn as_bind_group_shader_type(&self, images: &RenderAssets<GpuImage>) -> T;\n}\n\nimpl<T, U: ShaderType> AsBindGroupShaderType<U> for T\nwhere","sourceCodeStart":853,"sourceCodeEnd":889,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_render/src/render_resource/bind_group.rs#L853-L889","documentation":"UnpreparedBindingResource::get_binding() (bind_group.rs:871) panics on the Data variant because a raw value range corresponds to no binding by itself - it must be packed into a buffer by the MaterialBindGroupAllocator before it can be bound. The panic mirrors the OwnedBindingResource::Data case one level earlier, on the unprepared representation.","triggerScenarios":"Calling get_binding() on UnpreparedBindingResource::Data - typical when hand-building a bind group from an unprepared material's binding list instead of using the allocator/packing path.","commonSituations":"Custom material code that iterates unprepared bindings uniformly; data-slot-based materials (values packed into shared buffers); migrating older code that assumed every binding had a direct resource.","solutions":["Route Data through the MaterialBindGroupAllocator (packing into a slotted buffer) rather than get_binding().","Use Buffer/TextureView/Sampler variants for resources you intend to bind directly.","Go through as_bind_group()/the standard material preparation, which handles Data packing."],"exampleFix":"// before\nlet binding = unprepared.get_binding(); // panics on Data(_)\n\n// after\nmatch &unprepared {\n    UnpreparedBindingResource::Data(_) => { /* handled by MaterialBindGroupAllocator packing */ }\n    other => { let binding = other.get_binding(); }\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"fn unprepared_is_directly_bindable(res: &UnpreparedBindingResource) -> bool {\n    !matches!(res, UnpreparedBindingResource::Data(_))\n}","tryCatchPattern":null,"preventionTips":["Handle the Data variant explicitly (allocator packing) whenever iterating unprepared bindings.","Bind only Buffer/TextureView/Sampler variants directly.","Use as_bind_group()/standard preparation instead of hand-building groups from unprepared data."],"tags":["bevy","unprepared-binding","data","panic","bind-group"],"backgroundTag":"unsupported-variant-access","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}