{"record":{"id":"bc59ebd8fa63fd52","repo":"embassy-rs/embassy","slug":"extended-filter-slot-too-high","errorCode":null,"errorMessage":"Extended Filter Slot Too High!","messagePattern":"Extended Filter Slot Too High!","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"embassy-stm32/src/can/fd/filter.rs","lineNumber":309,"sourceCode":"    /// 5\n    _5 = 5,\n    /// 6\n    _6 = 6,\n    /// 7\n    _7 = 7,\n}\nimpl From<u8> for ExtendedFilterSlot {\n    fn from(u: u8) -> Self {\n        match u {\n            0 => ExtendedFilterSlot::_0,\n            1 => ExtendedFilterSlot::_1,\n            2 => ExtendedFilterSlot::_2,\n            3 => ExtendedFilterSlot::_3,\n            4 => ExtendedFilterSlot::_4,\n            5 => ExtendedFilterSlot::_5,\n            6 => ExtendedFilterSlot::_6,\n            7 => ExtendedFilterSlot::_7,\n            _ => panic!(\"Extended Filter Slot Too High!\"), // Should be unreachable\n        }\n    }\n}\n\n/// Enum over both Standard and Extended Filter ID's\n#[derive(Debug, Copy, Clone, Eq, PartialEq)]\npub enum FilterId {\n    /// Standard Filter Slots\n    Standard(StandardFilterSlot),\n    /// Extended Filter Slots\n    Extended(ExtendedFilterSlot),\n}\n\npub(crate) trait ActivateFilter<ID, UNIT>\nwhere\n    ID: Copy + Clone + core::fmt::Debug,\n    UNIT: Copy + Clone + core::fmt::Debug,\n{","sourceCodeStart":291,"sourceCodeEnd":327,"githubUrl":"https://github.com/embassy-rs/embassy/blob/463a07b963419a1bfe61d5d597c44acb810afb8b/embassy-stm32/src/can/fd/filter.rs#L291-L327","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure the filter slot index is in 0..=7 before converting to ExtendedFilterSlot.","Clamp or assert the index at the call site: `assert!(idx < 8)`.","Use the enum variants directly (ExtendedFilterSlot::_0.._7) instead of raw integer conversion."],"exampleFix":"// before\nlet slot = ExtendedFilterSlot::from(idx); // idx may be >= 8\n// after\nassert!(idx <= 7, \"extended filter slot index out of range\");\nlet slot = ExtendedFilterSlot::from(idx);","handlingStrategy":"validation","validationCode":"fn is_valid_extended_slot(idx: usize) -> bool { idx <= 7 }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember the FDCAN extended filter table has exactly 8 slots (0-7).","Use the ExtendedFilterSlot enum variants rather than raw integers.","Clamp filter indices when deriving them from dynamic lists."],"tags":["embedded","can","panic","range-check"],"backgroundTag":"value-out-of-range","analyzedSha":"463a07b963419a1bfe61d5d597c44acb810afb8b","analyzedAt":"2026-09-10T13:38:26.660Z","contentChangedAt":"2026-09-10T13:38:26.660Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}