{"record":{"id":"17b5e507d3c37268","repo":"Pumpkin-MC/Pumpkin","slug":"unexpected-event-type-17b5e5","errorCode":null,"errorMessage":"unexpected event type","messagePattern":"unexpected event type","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/pumpkin/src/plugin/loader/wasm/wasm_host/wit/v0_1/events/player.rs","lineNumber":2395,"sourceCode":"\n    fn apply_wasm_event(&mut self, event: Event, state: &mut PluginHostState) {\n        cleanup_event(&event, state);\n        if let Event::PlayerRecipeBookClickEvent(data) = event {\n            self.cancelled = data.cancelled;\n            self.recipe_id = data.recipe_id;\n            self.make_all = data.make_all;\n        }\n    }\n\n    fn from_wasm_event(event: Event, state: &mut PluginHostState) -> Self {\n        match event {\n            Event::PlayerRecipeBookClickEvent(data) => Self {\n                player: consume_player(state, &data.player),\n                recipe_id: data.recipe_id,\n                make_all: data.make_all,\n                cancelled: data.cancelled,\n            },\n            _ => panic!(\"unexpected event type\"),\n        }\n    }\n}\n\nimpl ToFromWasmEvent for PlayerRecipeBookSettingsChangeEvent {\n    fn to_wasm_event(&self, state: &mut PluginHostState) -> Event {\n        let player = state\n            .add_player(self.player.clone())\n            .expect(\"failed to add player resource\");\n        Event::PlayerRecipeBookSettingsChangeEvent(PlayerRecipeBookSettingsChangeEventData {\n            player,\n            book_type: self.book_type.clone(),\n            is_open: self.is_open,\n            is_filtering: self.is_filtering,\n            cancelled: self.cancelled,\n        })\n    }\n","sourceCodeStart":2377,"sourceCodeEnd":2413,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin/src/plugin/loader/wasm/wasm_host/wit/v0_1/events/player.rs#L2377-L2413","documentation":"Wildcard `_ => panic!(\"unexpected event type\")` in the `from_wasm_event` impl for `PlayerRecipeBookClickEvent` (player.rs). The converter asserts the incoming `Event` is exactly `Event::PlayerRecipeBookClickEvent`; any other variant means the host routed the event incorrectly.","triggerScenarios":"The WASM dispatch layer delivers a non-matching Event variant to this converter — from a stale dispatch table, mismatched wit bindings, or a newly added player event variant not wired into the conversion registry.","commonSituations":"Host/plugin version skew on v0_1 event enums, forks adding recipe-book variants, or macro-generated plugin_method dispatch out of sync with the hand-written impls.","solutions":["Ensure the dispatcher maps Event::PlayerRecipeBookClickEvent to this impl exclusively.","Rebuild host and plugins from the same pumpkin-api revision.","Log the received variant in the panic message.","Return a conversion error instead of panicking so one bad event cannot abort the host."],"exampleFix":"// before\n_ => panic!(\"unexpected event type\"),\n// after\nother => panic!(\"PlayerRecipeBookClickEvent::from_wasm_event got {other:?}\"),","handlingStrategy":"type-guard","validationCode":"debug_assert!(matches!(event, Event::PlayerRecipeBookClickEvent(_)));","typeGuard":"fn is_recipe_book_click(e: &Event) -> bool { matches!(e, Event::PlayerRecipeBookClickEvent(_)) }","tryCatchPattern":"std::panic::catch_unwind(|| from_wasm_event(event, state)).unwrap_or_else(|_| log_misroute())","preventionTips":["Keep dispatch generation and impls in lockstep","Rebuild plugins after any host enum change","Assert variant at dispatch boundaries in debug builds","Route only through generated plugin_method dispatch"],"tags":["rust","wasm","plugin-api","panic","event-conversion"],"backgroundTag":"internal-invariant-violation","analyzedSha":"8d4639e25a57c15e47448ec327c780d41bbf2356","analyzedAt":"2026-09-09T15:32:22.916Z","contentChangedAt":"2026-09-09T15:32:22.916Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}