{"record":{"id":"160c4e9ad19e726c","repo":"Pumpkin-MC/Pumpkin","slug":"expected-serverlistpingevent","errorCode":null,"errorMessage":"expected ServerListPingEvent","messagePattern":"expected ServerListPingEvent","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/pumpkin-plugin-api/src/events/server/server_list_ping.rs","lineNumber":18,"sourceCode":"use crate::wit::pumpkin::plugin::event::{Event, EventType, ServerListPingEventData};\n\nuse super::super::FromIntoEvent;\n\n/// Fires when the server prepares a Java status/list ping response.\n///\n/// Register this as a blocking event handler to customize the MOTD, favicon,\n/// and reported player counts for WASM plugins.\npub struct ServerListPingEvent;\n\nimpl FromIntoEvent for ServerListPingEvent {\n    const EVENT_TYPE: EventType = EventType::ServerListPingEvent;\n    type Data = ServerListPingEventData;\n\n    fn data_from_event(event: Event) -> Self::Data {\n        match event {\n            Event::ServerListPingEvent(data) => data,\n            _ => panic!(\"expected ServerListPingEvent\"),\n        }\n    }\n\n    fn data_into_event(data: Self::Data) -> Event {\n        Event::ServerListPingEvent(data)\n    }\n}\n","sourceCodeStart":1,"sourceCodeEnd":26,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin-plugin-api/src/events/server/server_list_ping.rs#L1-L26","documentation":"This panic comes from the `EventLike` trait's `data_from_event` glue for ServerListPingEvent. The event dispatcher hands an `Event` enum to the handler bridge, which destructures it into its typed payload; if the variant is not `Event::ServerListPingEvent`, the bridge panics with \"expected ServerListPingEvent\". This means the internal event-routing invariants were violated — the dispatcher delivered an event to a handler registered for a different event type.","triggerScenarios":"Calling `data_from_event` (directly or via the plugin-event bridge) with an `Event` variant other than `Event::ServerListPingEvent` — e.g. an event bus that registered a ServerListPing listener under the wrong EventType key, or hand-rolled dispatch code that passes raw events to the wrong trait implementation.","commonSituations":"Plugin API version changes that renamed/reordered Event variants so old dispatch tables map to the wrong handler; a custom scheduler or event forwarder that mixes up EventType registration keys; writing a custom EventLike impl and copying the wrong Data type into it.","solutions":["Verify the handler is registered under EventType::ServerListPingEvent so the dispatcher routes matching variants to it.","Update the plugin API and dispatcher to the same version so Event enum variants and EventType keys stay in sync.","Check any custom event forwarding code for a swap between ServerListPingEvent and another Event variant.","Replace the panic with a logged error / no-op if the bridge should tolerate misrouted events."],"exampleFix":"// before\nEvent::ServerListPingEvent(data) => data,\n_ => panic!(\"expected ServerListPingEvent\"),\n// after\nEvent::ServerListPingEvent(data) => data,\nother => {\n    log::warn!(\"misrouted event {:?}, expected ServerListPingEvent\", other.event_type());\n    return Default::default();\n}","handlingStrategy":"validation","validationCode":"// assert route correctness before invoking the bridge\nassert_eq!(<ServerListPingHandler as EventLike>::EVENT_TYPE, event.event_type(), \"misrouted event\");","typeGuard":"fn as_server_list_ping<'a>(event: &'a Event) -> Option<&'a ServerListPingEventData> {\n    if let Event::ServerListPingEvent(data) = event { Some(data) } else { None }\n}","tryCatchPattern":"// Rust panics are not catchable across FFI; use catch_unwind at the dispatch boundary\nlet result = std::panic::catch_unwind(AssertUnwindSafe(|| bridge.data_from_event(event)));\nif result.is_err() { log::error!(\"misrouted event for ServerListPingEvent handler\"); }","preventionTips":["Always register handlers with the exact EventType constant defined by their EventLike impl","Keep the plugin crate and server on the same pumpkin-plugin-api version","In custom dispatchers, filter events by event_type() before invoking a handler","Prefer matching with `if let Event::Variant(..)` over panicking bridges in your own glue"],"tags":["panic","event-dispatch","plugin-api","rust"],"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-15T23:17:13.987Z"}