{"record":{"id":"13388e4e407f2fd4","repo":"Pumpkin-MC/Pumpkin","slug":"unexpected-event-13388e","errorCode":null,"errorMessage":"unexpected event","messagePattern":"unexpected event","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/pumpkin-plugin-api/src/events/entity/entity_resurrect.rs","lineNumber":14,"sourceCode":"use crate::wit::pumpkin::plugin::event::{EntityResurrectEventData, Event, EventType};\n\nuse super::super::FromIntoEvent;\n\n/// Event triggered when an entity is resurrected.\npub struct EntityResurrectEvent;\nimpl FromIntoEvent for EntityResurrectEvent {\n    const EVENT_TYPE: EventType = EventType::EntityResurrectEvent;\n    type Data = EntityResurrectEventData;\n\n    fn data_from_event(event: Event) -> Self::Data {\n        match event {\n            Event::EntityResurrectEvent(data) => data,\n            _ => panic!(\"unexpected event\"),\n        }\n    }\n\n    fn data_into_event(data: Self::Data) -> Event {\n        Event::EntityResurrectEvent(data)\n    }\n}\n","sourceCodeStart":1,"sourceCodeEnd":22,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin-plugin-api/src/events/entity/entity_resurrect.rs#L1-L22","documentation":"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.","triggerScenarios":"`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`.","commonSituations":"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.","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"],"exampleFix":"// before\nmatch event {\n    Event::EntityResurrectEvent(data) => data,\n    _ => panic!(\"unexpected event\"),\n}\n// after\nmatch event {\n    Event::EntityResurrectEvent(data) => Ok(data),\n    _ => Err(\"unexpected event\"),\n}","handlingStrategy":"try-catch","validationCode":"if event.event_type() != EventType::EntityResurrectEvent {\n    return; // skip: not an EntityResurrectEvent\n}","typeGuard":"fn as_entity_resurrect(event: &Event) -> Option<&EntityResurrectEventData> {\n    match event {\n        Event::EntityResurrectEvent(data) => Some(data),\n        _ => None,\n    }\n}","tryCatchPattern":"let data = std::panic::catch_unwind(|| EntityResurrectEvent::data_from_event(event))\n    .unwrap_or_else(|_| { log::error!(\"event type mismatch for EntityResurrectEvent\"); return; });","preventionTips":["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"],"tags":["rust","panic","event-dispatch","plugin-api","internal-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"}