Pumpkin-MC/Pumpkin · error
unexpected event
Error message
unexpected event
What it means
This panic fires in `FromIntoEvent::data_from_event` when an `Event` passed to `EntityResurrectEvent`'s converter carries any variant other than `Event::EntityResurrectEvent`. The trait bridges the WIT-generated `Event` enum to this event's typed `Data`, assuming dispatch always pairs the event type with its matching variant. A mismatched variant means the dispatch plumbing broke that invariant, so the library aborts instead of returning wrong data.
Solutions
- Ensure host and pumpkin-plugin-api versions match so `EventType::EntityResurrectEvent` maps to `Event::EntityResurrectEvent`
- Audit the dispatcher so only `EventType::EntityResurrectEvent` reaches this converter
- Filter events by `EVENT_TYPE` before calling `data_from_event` in custom dispatch code
- Return a `Result` or log-and-drop instead of panicking on mismatch
Example fix
// before
match event {
Event::EntityResurrectEvent(data) => data,
_ => panic!("unexpected event"),
}
// after
match event {
Event::EntityResurrectEvent(data) => Ok(data),
_ => Err("unexpected event"),
} Defensive patterns
Strategy: try-catch
Validate before calling
if event.event_type() != EventType::EntityResurrectEvent {
return; // skip: not an EntityResurrectEvent
} Type guard
fn as_entity_resurrect(event: &Event) -> Option<&EntityResurrectEventData> {
match event {
Event::EntityResurrectEvent(data) => Some(data),
_ => None,
}
} Try / catch
let data = std::panic::catch_unwind(|| EntityResurrectEvent::data_from_event(event))
.unwrap_or_else(|_| { log::error!("event type mismatch for EntityResurrectEvent"); return; }); Prevention
- Keep host and plugin API versions aligned
- Check `EVENT_TYPE` before unwrapping an event
- Route each `Event` variant only to its matching handler
- Add a dispatcher test asserting type-to-variant pairing
When it happens
Trigger: `data_from_event` is invoked with an `Event` that is not `Event::EntityResurrectEvent` — the dispatcher routed a different event to the `EntityResurrectEvent` handler, or the `EventType` tag and `Event` variant disagree due to version skew or a hand-rolled dispatch that ignores `EventType`.
Common situations: Host and plugin API versions out of sync so enum variants no longer line up; a custom event bus forwarding raw `Event` values without type checks; registering `EntityResurrectEvent` under the wrong `EventType` in a refactored dispatcher.
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
AI-assisted analysis of Pumpkin-MC/Pumpkin@8d4639e25a (2026-09-09).
Data as JSON: /api/errors/13388e4e407f2fd4.
Report an issue: GitHub.
Appendix: source
Thrown at crates/pumpkin-plugin-api/src/events/entity/entity_resurrect.rs:14
use crate::wit::pumpkin::plugin::event::{EntityResurrectEventData, Event, EventType};
use super::super::FromIntoEvent;
/// Event triggered when an entity is resurrected.
pub struct EntityResurrectEvent;
impl FromIntoEvent for EntityResurrectEvent {
const EVENT_TYPE: EventType = EventType::EntityResurrectEvent;
type Data = EntityResurrectEventData;
fn data_from_event(event: Event) -> Self::Data {
match event {
Event::EntityResurrectEvent(data) => data,
_ => panic!("unexpected event"),
}
}
fn data_into_event(data: Self::Data) -> Event {
Event::EntityResurrectEvent(data)
}
}
View on GitHub (pinned to 8d4639e25a)