bevyengine/bevy · error

A slot in the resource_to_slot map should have a value

Error message

A slot in the resource_to_slot map should have a value

What it means

Internal invariant expect in the bindless binding-array bookkeeping: a resource_to_slot lookup expected an existing slot for the resource but found none, indicating the slot map is out of sync with the bindings.

Source

Thrown at crates/bevy_render/src/material_bind_groups.rs:2130

        self.bindings
            .get(slot as usize)
            .is_some_and(|maybe_binding| {
                maybe_binding.as_ref().is_some_and(|binding| {
                    binding.resource.binding_resource_id(self.resource_type) == binding_resource_id
                })
            })
    }

    /// Inserts a bindless resource into a binding array and returns the index
    /// of the slot it was inserted into.
    fn insert(&mut self, binding_resource_id: BindingResourceId, resource: R) -> u32 {
        match self.resource_to_slot.entry(binding_resource_id) {
            Entry::Occupied(o) => {
                let slot = *o.get();

                self.bindings[slot as usize]
                    .as_mut()
                    .expect("A slot in the resource_to_slot map should have a value")
                    .ref_count += 1;

                slot
            }
            Entry::Vacant(v) => {
                let slot = self.free_slots.pop().unwrap_or(self.len);
                v.insert(slot);

                if self.bindings.len() < slot as usize + 1 {
                    self.bindings.resize_with(slot as usize + 1, || None);
                }
                debug_assert!(self.bindings[slot as usize].is_none());
                self.bindings[slot as usize] = Some(MaterialBindlessBinding::new(resource));

                self.len += 1;
                slot
            }
        }

View on GitHub (pinned to 396ca72708)

Solutions

  1. Report as a Bevy engine bug with a reproducing project
  2. Avoid the resource add/remove sequence that triggers the desync
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at crates/bevy_render/src/material_bind_groups.rs:2130 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of bevyengine/bevy@396ca72708 (2026-08-20). Data as JSON: /api/errors/ba4522804684ef46. Report an issue: GitHub.