{"record":{"id":"143b6d9f13d0c05f","repo":"linebender/druid","slug":"unrecognised-key-event","errorCode":null,"errorMessage":"unrecognised key event","messagePattern":"unrecognised key event","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"druid-shell/src/backend/wayland/keyboard.rs","lineNumber":116,"sourceCode":"                if last.key != current.key {\n                    return Some(last.clone());\n                }\n                None\n            }\n        }\n    }\n\n    fn keystroke<'a>(&'a mut self, keystroke: &'a CachedKeyPress) {\n        let keystate = match keystroke.state {\n            wl_keyboard::KeyState::Released => {\n                self.replace_last_key_press(self.release_last_key_press(keystroke));\n                KeyState::Up\n            }\n            wl_keyboard::KeyState::Pressed => {\n                self.replace_last_key_press(Some(keystroke.repeat()));\n                KeyState::Down\n            }\n            _ => panic!(\"unrecognised key event\"),\n        };\n\n        let mut event = self.xkb_state.borrow_mut().as_mut().unwrap().key_event(\n            keystroke.key,\n            keystate,\n            keystroke.repeat,\n        );\n        event.mods = self.xkb_mods.get();\n\n        if let Err(cause) = keystroke.queue.send(event) {\n            tracing::error!(\"failed to send Druid key event: {:?}\", cause);\n        }\n    }\n\n    fn consume(\n        &mut self,\n        seat: u32,\n        event: wl_keyboard::Event,","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/linebender/druid/blob/0f8b1195e4e073f9597f2865299c3d18f8e4005f/druid-shell/src/backend/wayland/keyboard.rs#L98-L134","documentation":"The Wayland keyboard handler panics when a key event's `KeyState` is neither `Released` nor `Pressed`. The code maps known states to `KeyState::Up`/`Down` and treats any other value as unrecoverable because it cannot be interpreted.","triggerScenarios":"A `wl_keyboard::KeyState` value arrives from the compositor that is not `Released` or `Pressed` (unknown enum value), reaching `keystroke` processing via `consume`.","commonSituations":"A compositor or wayland protocol extension emitting a new/unknown key state; protocol desync after a malformed event.","solutions":["Update the wayland client library so unknown enum values are handled explicitly","Patch the handler to log and skip unknown key states instead of panicking","Verify compositor compatibility / protocol version negotiation"],"exampleFix":"// before\n_ => panic!(\"unrecognised key event\"),\n\n// after\nother => {\n    tracing::warn!(\"unrecognised key state: {:?}\", other);\n    return;\n}","handlingStrategy":"try-catch","validationCode":"// Can't validate remote enum values; guard at the handler boundary by matching exhaustively before processing","typeGuard":"fn is_known_key_state(s: wl_keyboard::KeyState) -> bool {\n    matches!(s, wl_keyboard::KeyState::Released | wl_keyboard::KeyState::Pressed)\n}","tryCatchPattern":"std::panic::catch_unwind(AssertUnwindSafe(|| process_key(evt)))\n  .unwrap_or_else(|_| log::warn!(\"skipped unknown key state\"));","preventionTips":["Keep the wayland client crate up to date for new protocol enum variants","Favor logging-and-skipping over panicking in event handlers","Test against multiple compositors to surface unknown states early"],"tags":["wayland","keyboard","panic","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"0f8b1195e4e073f9597f2865299c3d18f8e4005f","analyzedAt":"2026-09-10T14:27:34.582Z","contentChangedAt":"2026-09-10T14:27:34.582Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}