Pumpkin-MC/Pumpkin · critical
unexpected event type
Error message
unexpected event type
What it means
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.
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
Defensive patterns
Strategy: type-guard
Validate before calling
// dispatch check
fn expects(ev: &Event, want: &str) -> bool { format!("{:?}", ev).starts_with(want) } Type guard
fn matches_variant(ev: &Event) -> bool { matches!(ev, Event::BlockFertilizeEvent(_) | Event::BlockMultiPlaceEvent(_)) } Prevention
- 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
When it happens
Trigger: A converter for one event type (e.g. BlockFertilizeEvent or BlockMultiPlaceEvent) receives a different Event variant than it expects during WASM event conversion.
Common situations: 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.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- Cannot construct BlockFertilizeEvent from WASM
- failed to add player resource
- failed to add world resource
- Cannot construct BlockMultiPlaceEvent from WASM
- unexpected event type
AI-assisted analysis of Pumpkin-MC/Pumpkin@8d4639e25a (2026-09-09).
Data as JSON: /api/errors/fee3bc24540f0485.
Report an issue: GitHub.
Appendix: source
Thrown at crates/pumpkin/src/plugin/loader/wasm/wasm_host/wit/v0_1/events/block.rs:906
player,
changed_blocks,
cancelled: self.cancelled,
})
}
fn apply_wasm_event(&mut self, event: Event, state: &mut PluginHostState) {
cleanup_event(&event, state);
if let Event::BlockFertilizeEvent(data) = event {
self.cancelled = data.cancelled;
}
}
fn from_wasm_event(event: Event, _state: &mut PluginHostState) -> Self {
match event {
Event::BlockFertilizeEvent(_) => {
panic!("Cannot construct BlockFertilizeEvent from WASM")
}
_ => panic!("unexpected event type"),
}
}
}
impl ToFromWasmEvent for BlockMultiPlaceEvent {
fn to_wasm_event(&self, state: &mut PluginHostState) -> Event {
let player = state
.add_player(self.player.clone())
.expect("failed to add player resource");
let target_world = state
.add_world(self.world.clone())
.expect("failed to add world resource");
let placed_blocks = self
.placed_blocks
.iter()
.map(|(pos, id)| (to_wasm_block_position(*pos), id.as_u16()))
.collect();
Event::BlockMultiPlaceEvent(BlockMultiPlaceEventData {View on GitHub (pinned to 8d4639e25a)