{"record":{"id":"fee3bc24540f0485","repo":"Pumpkin-MC/Pumpkin","slug":"unexpected-event-type","errorCode":null,"errorMessage":"unexpected event type","messagePattern":"unexpected event type","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/pumpkin/src/plugin/loader/wasm/wasm_host/wit/v0_1/events/block.rs","lineNumber":906,"sourceCode":"            player,\n            changed_blocks,\n            cancelled: self.cancelled,\n        })\n    }\n\n    fn apply_wasm_event(&mut self, event: Event, state: &mut PluginHostState) {\n        cleanup_event(&event, state);\n        if let Event::BlockFertilizeEvent(data) = event {\n            self.cancelled = data.cancelled;\n        }\n    }\n\n    fn from_wasm_event(event: Event, _state: &mut PluginHostState) -> Self {\n        match event {\n            Event::BlockFertilizeEvent(_) => {\n                panic!(\"Cannot construct BlockFertilizeEvent from WASM\")\n            }\n            _ => panic!(\"unexpected event type\"),\n        }\n    }\n}\n\nimpl ToFromWasmEvent for BlockMultiPlaceEvent {\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        let target_world = state\n            .add_world(self.world.clone())\n            .expect(\"failed to add world resource\");\n        let placed_blocks = self\n            .placed_blocks\n            .iter()\n            .map(|(pos, id)| (to_wasm_block_position(*pos), id.as_u16()))\n            .collect();\n        Event::BlockMultiPlaceEvent(BlockMultiPlaceEventData {","sourceCodeStart":888,"sourceCodeEnd":924,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin/src/plugin/loader/wasm/wasm_host/wit/v0_1/events/block.rs#L888-L924","documentation":"The fallback arm of the match in from_wasm_event: any event type other than the expected one reaches `_ => panic!(\"unexpected event type\")`. It signals an internal dispatch bug — the wrong Event variant was passed to a specific event type's converter.","triggerScenarios":"A converter for one event type (e.g. BlockFertilizeEvent or BlockMultiPlaceEvent) receives a different Event variant than it expects during WASM event conversion.","commonSituations":"Macro-generated dispatch (crates/pumpkin-api-macros) mismatched with hand-written from_wasm_event impls; new event variant added without updating the converter table; server/plugin version skew.","solutions":["Verify the event dispatch macro maps each event to its matching ToFromWasmEvent impl","Update converters after adding new Event variants","Pin plugin and server to the same API version","Read the surrounding panic context to identify which converter was mis-dispatched"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// dispatch check\nfn expects(ev: &Event, want: &str) -> bool { format!(\"{:?}\", ev).starts_with(want) }","typeGuard":"fn matches_variant(ev: &Event) -> bool { matches!(ev, Event::BlockFertilizeEvent(_) | Event::BlockMultiPlaceEvent(_)) }","tryCatchPattern":null,"preventionTips":["Keep the dispatch table and per-event converters in sync (covered by tests)","Regenerate/audit converters when adding Event variants","Pin plugin bindings to the same API version as the server"],"tags":["panic","wasm","events","dispatch","invariant"],"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"}