{"record":{"id":"502307ef0bd3d9f1","repo":"Pumpkin-MC/Pumpkin","slug":"unexpected-event-502307","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_shoot_bow.rs","lineNumber":14,"sourceCode":"use crate::wit::pumpkin::plugin::event::{EntityShootBowEventData, Event, EventType};\n\nuse super::super::FromIntoEvent;\n\n/// Event triggered when an entity shoots a bow.\npub struct EntityShootBowEvent;\nimpl FromIntoEvent for EntityShootBowEvent {\n    const EVENT_TYPE: EventType = EventType::EntityShootBowEvent;\n    type Data = EntityShootBowEventData;\n\n    fn data_from_event(event: Event) -> Self::Data {\n        match event {\n            Event::EntityShootBowEvent(data) => data,\n            _ => panic!(\"unexpected event\"),\n        }\n    }\n\n    fn data_into_event(data: Self::Data) -> Event {\n        Event::EntityShootBowEvent(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_shoot_bow.rs#L1-L22","documentation":"This panic fires in `FromIntoEvent::data_from_event` when an `Event` passed to `EntityShootBowEvent`'s converter carries any variant other than `Event::EntityShootBowEvent`. The trait bridges the WIT-generated `Event` enum to this event's typed `Data`, assuming the dispatch layer always pairs event type and variant. A mismatch means that invariant was violated and the library aborts rather than misinterpreting the payload.","triggerScenarios":"`data_from_event` is invoked with an `Event` that is not `Event::EntityShootBowEvent` — a dispatcher routed a different event to the `EntityShootBowEvent` handler, or `EventType` tagging and the `Event` variant disagree (host/plugin version skew or a dispatch ignoring `EventType`).","commonSituations":"Mismatched host and pumpkin-plugin-api versions; a custom event bus forwarding raw `Event` values untyped; registering `EntityShootBowEvent` under the wrong `EventType` key.","solutions":["Align host and plugin API versions so `EventType::EntityShootBowEvent` maps to `Event::EntityShootBowEvent`","Ensure the dispatcher routes only `EventType::EntityShootBowEvent` to this converter","In custom dispatch code, check `EVENT_TYPE` before unwrapping the event","Convert the panic into a `Result` or logged error for graceful failure"],"exampleFix":"// before\nmatch event {\n    Event::EntityShootBowEvent(data) => data,\n    _ => panic!(\"unexpected event\"),\n}\n// after\nmatch event {\n    Event::EntityShootBowEvent(data) => Ok(data),\n    _ => Err(\"unexpected event\"),\n}","handlingStrategy":"try-catch","validationCode":"if event.event_type() != EventType::EntityShootBowEvent {\n    return; // skip: not an EntityShootBowEvent\n}","typeGuard":"fn as_entity_shoot_bow(event: &Event) -> Option<&EntityShootBowEventData> {\n    match event {\n        Event::EntityShootBowEvent(data) => Some(data),\n        _ => None,\n    }\n}","tryCatchPattern":"let data = std::panic::catch_unwind(|| EntityShootBowEvent::data_from_event(event))\n    .unwrap_or_else(|_| { log::error!(\"event type mismatch for EntityShootBowEvent\"); return; });","preventionTips":["Match host and plugin API versions","Dispatch by `EVENT_TYPE` before calling `data_from_event`","Do not reuse a handler for multiple `Event` variants","Cover type-to-variant pairing in dispatcher tests"],"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"}