embassy-rs/embassy · error

Extended Filter Slot Too High!

Error message

Extended Filter Slot Too High!

What it means

Panic raised in `ExtendedId::into()` conversion when converting a filter index slot number into an `ExtendedFilterSlot` enum with a value above 7. The FDCAN peripheral only supports 8 extended filter slots (0-7), so the match treats any higher value as an unreachable internal invariant. Hitting it means a caller supplied an out-of-range filter slot index.

Solutions

  1. Ensure the filter slot index is in 0..=7 before converting to ExtendedFilterSlot.
  2. Clamp or assert the index at the call site: `assert!(idx < 8)`.
  3. Use the enum variants directly (ExtendedFilterSlot::_0.._7) instead of raw integer conversion.

Example fix

// before
let slot = ExtendedFilterSlot::from(idx); // idx may be >= 8
// after
assert!(idx <= 7, "extended filter slot index out of range");
let slot = ExtendedFilterSlot::from(idx);
Defensive patterns

Strategy: validation

Validate before calling

fn is_valid_extended_slot(idx: usize) -> bool { idx <= 7 }

Prevention

When it happens

Trigger: Calling the `From<usize>/u8 -> ExtendedFilterSlot` conversion (in `from`) with a value > 7, e.g. passing slot index 8+ when configuring an extended CAN filter via `set_filter` / filter slot APIs.

Common situations: Looping over a filter list without clamping to the 8-slot limit; off-by-one when assigning the Nth filter; porting code written for chips with more filter banks.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of embassy-rs/embassy@463a07b963 (2026-09-10). Data as JSON: /api/errors/bc59ebd8fa63fd52. Report an issue: GitHub.

Appendix: source

Thrown at embassy-stm32/src/can/fd/filter.rs:309

    /// 5
    _5 = 5,
    /// 6
    _6 = 6,
    /// 7
    _7 = 7,
}
impl From<u8> for ExtendedFilterSlot {
    fn from(u: u8) -> Self {
        match u {
            0 => ExtendedFilterSlot::_0,
            1 => ExtendedFilterSlot::_1,
            2 => ExtendedFilterSlot::_2,
            3 => ExtendedFilterSlot::_3,
            4 => ExtendedFilterSlot::_4,
            5 => ExtendedFilterSlot::_5,
            6 => ExtendedFilterSlot::_6,
            7 => ExtendedFilterSlot::_7,
            _ => panic!("Extended Filter Slot Too High!"), // Should be unreachable
        }
    }
}

/// Enum over both Standard and Extended Filter ID's
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum FilterId {
    /// Standard Filter Slots
    Standard(StandardFilterSlot),
    /// Extended Filter Slots
    Extended(ExtendedFilterSlot),
}

pub(crate) trait ActivateFilter<ID, UNIT>
where
    ID: Copy + Clone + core::fmt::Debug,
    UNIT: Copy + Clone + core::fmt::Debug,
{

View on GitHub (pinned to 463a07b963)