Pumpkin-MC/Pumpkin · error
unexpected event type
Error message
unexpected event type
What it means
The EntityRegainHealthEvent from-conversion panics "unexpected event type" when the WIT Event it receives is not Event::EntityRegainHealthEvent. Each event converter handles exactly one variant, and the catch-all arm exists only to exhaust the match; reaching it means the host dispatcher routed the wrong event into this converter. The panic aborts the plugin host.
Solutions
- Regenerate WIT bindings and the event dispatch so each variant maps to its converter
- Synchronize Pumpkin host and pumpkin plugin API versions
- Audit newly added Event variants for missing converter/dispatch registration
- In a fork, return an error and skip the event instead of panicking
Example fix
// before
_ => panic!("unexpected event type"),
// after
other => {
log::error!("EntityRegainHealthEvent converter got unexpected event: {other:?}");
return Err("unexpected event type".into());
} Defensive patterns
Strategy: try-catch
Validate before calling
assert!(matches!(event, Event::EntityRegainHealthEvent(_)), "converter/dispatch mismatch for EntityRegainHealthEvent");
Type guard
fn is_regain_health(e: &Event) -> bool {
matches!(e, Event::EntityRegainHealthEvent(_))
} Try / catch
let result = std::panic::catch_unwind(|| dispatch_to_plugins(event));
if result.is_err() { log::error!("plugin host panicked converting EntityRegainHealthEvent"); } Prevention
- Regenerate bindings after adding entity event variants
- Match host/plugin API versions exactly
- Add exhaustive-match CI checks over Event variants
- Use the dispatcher, never manual converter calls
When it happens
Trigger: The WASM event deserialization layer (from_wasm_event) delivers any Event variant other than EntityRegainHealthEvent to this converter — normally only possible if the dispatch table is stale or the Event enum changed without regenerating glue.
Common situations: Adding new entity event variants without updating dispatch; mismatched plugin-API and host versions; macro-generated converters out of sync with the handwritten WIT enum.
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 BlockReceiveGameEvent from WASM
- failed to add item stack resource
- Cannot construct BlockShearEntityEvent from WASM
- Cannot construct CrafterCraftEvent from WASM
- Cannot construct EntityBlockFormEvent from WASM
AI-assisted analysis of Pumpkin-MC/Pumpkin@8d4639e25a (2026-09-09).
Data as JSON: /api/errors/1c1ad48f81efe272.
Report an issue: GitHub.
Appendix: source
Thrown at crates/pumpkin/src/plugin/loader/wasm/wasm_host/wit/v0_1/events/entity.rs:258
}
impl ToFromWasmEvent for EntityRegainHealthEvent {
fn to_wasm_event(&self, _state: &mut PluginHostState) -> Event {
Event::EntityRegainHealthEvent(EntityRegainHealthEventData {
entity_id: self.entity_id,
amount: self.amount,
cancelled: self.cancelled,
})
}
fn from_wasm_event(event: Event, _state: &mut PluginHostState) -> Self {
match event {
Event::EntityRegainHealthEvent(data) => Self {
entity_id: data.entity_id,
amount: data.amount,
cancelled: data.cancelled,
},
_ => panic!("unexpected event type"),
}
}
}
impl ToFromWasmEvent
for crate::plugin::api::events::entity::entity_air_change::EntityAirChangeEvent
{
fn to_wasm_event(&self, _state: &mut PluginHostState) -> Event {
Event::EntityAirChangeEvent(EntityAirChangeEventData {
entity_id: self.entity_id,
amount: self.amount,
cancelled: self.cancelled,
})
}
fn from_wasm_event(event: Event, _state: &mut PluginHostState) -> Self {
match event {
Event::EntityAirChangeEvent(data) => Self {View on GitHub (pinned to 8d4639e25a)