{"record":{"id":"1c1ad48f81efe272","repo":"Pumpkin-MC/Pumpkin","slug":"unexpected-event-type-1c1ad4","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/entity.rs","lineNumber":258,"sourceCode":"}\n\nimpl ToFromWasmEvent for EntityRegainHealthEvent {\n    fn to_wasm_event(&self, _state: &mut PluginHostState) -> Event {\n        Event::EntityRegainHealthEvent(EntityRegainHealthEventData {\n            entity_id: self.entity_id,\n            amount: self.amount,\n            cancelled: self.cancelled,\n        })\n    }\n\n    fn from_wasm_event(event: Event, _state: &mut PluginHostState) -> Self {\n        match event {\n            Event::EntityRegainHealthEvent(data) => Self {\n                entity_id: data.entity_id,\n                amount: data.amount,\n                cancelled: data.cancelled,\n            },\n            _ => panic!(\"unexpected event type\"),\n        }\n    }\n}\n\nimpl ToFromWasmEvent\n    for crate::plugin::api::events::entity::entity_air_change::EntityAirChangeEvent\n{\n    fn to_wasm_event(&self, _state: &mut PluginHostState) -> Event {\n        Event::EntityAirChangeEvent(EntityAirChangeEventData {\n            entity_id: self.entity_id,\n            amount: self.amount,\n            cancelled: self.cancelled,\n        })\n    }\n\n    fn from_wasm_event(event: Event, _state: &mut PluginHostState) -> Self {\n        match event {\n            Event::EntityAirChangeEvent(data) => Self {","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin/src/plugin/loader/wasm/wasm_host/wit/v0_1/events/entity.rs#L240-L276","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\n_ => panic!(\"unexpected event type\"),\n// after\nother => {\n    log::error!(\"EntityRegainHealthEvent converter got unexpected event: {other:?}\");\n    return Err(\"unexpected event type\".into());\n}","handlingStrategy":"try-catch","validationCode":"assert!(matches!(event, Event::EntityRegainHealthEvent(_)), \"converter/dispatch mismatch for EntityRegainHealthEvent\");","typeGuard":"fn is_regain_health(e: &Event) -> bool {\n    matches!(e, Event::EntityRegainHealthEvent(_))\n}","tryCatchPattern":"let result = std::panic::catch_unwind(|| dispatch_to_plugins(event));\nif result.is_err() { log::error!(\"plugin host panicked converting EntityRegainHealthEvent\"); }","preventionTips":["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"],"tags":["wasm","plugin-host","panic","enum-mismatch","entity-events"],"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"}