Pumpkin-MC/Pumpkin · error
unexpected event
Error message
unexpected event
What it means
This panic fires inside `FromIntoEvent::data_from_event` for `ChunkPopulateEvent` when the passed `Event` variant is anything other than `Event::ChunkPopulateEvent`. The conversion exists to unwrap typed data after `EVENT_TYPE`-based routing; a foreign variant indicates the event bus misrouted the event or someone constructed the `Event` manually, and the handler panics.
Solutions
- Ensure the bus dispatches only `Event::ChunkPopulateEvent` to this handler.
- Synchronize plugin API and host builds to the same revision.
- Wrap payload as `Event::ChunkPopulateEvent(data)` in custom dispatch code.
- Add an integration test asserting each handler receives exactly its registered event type.
Example fix
// before
if is_chunk_event(&ev) { populate_handler(ev) } // any chunk event passes
// after
if matches!(ev, Event::ChunkPopulateEvent(_)) { populate_handler(ev) } Defensive patterns
Strategy: type-guard
Validate before calling
assert!(matches!(event, Event::ChunkPopulateEvent(_)), "handler requires Event::ChunkPopulateEvent");
Type guard
fn as_chunk_populate(ev: &Event) -> Option<&ChunkPopulateEventData> {
if let Event::ChunkPopulateEvent(d) = ev { Some(d) } else { None }
} Try / catch
// guard before dispatch:
if let Event::ChunkPopulateEvent(data) = event { handle(data) } else { log::warn!("mismatched event at chunk-populate handler") } Prevention
- Use `matches!` narrowing before invoking typed handlers.
- Keep event routing single-keyed on `EventType`.
- Pin host and plugin to identical API versions in lockstep CI.
- Cover each chunk lifecycle event with a dispatch test.
When it happens
Trigger: Delivering any other world event to a `ChunkPopulateEvent` handler, or invoking the macro-generated conversion with a mismatched `Event` in a custom harness.
Common situations: Alternate plugin hosts with incorrect event-to-handler keying; host/plugin version skew changing the `Event` enum; tests sharing one event across multiple registered handlers.
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/0100df039a3e6b8e.
Report an issue: GitHub.
Appendix: source
Thrown at crates/pumpkin-plugin-api/src/events/world/chunk_populate.rs:13
use super::super::FromIntoEvent;
use crate::wit::pumpkin::plugin::event::{ChunkPopulateEventData, Event, EventType};
/// Event triggered when a chunk is populated.
pub struct ChunkPopulateEvent;
impl FromIntoEvent for ChunkPopulateEvent {
const EVENT_TYPE: EventType = EventType::ChunkPopulateEvent;
type Data = ChunkPopulateEventData;
fn data_from_event(event: Event) -> Self::Data {
match event {
Event::ChunkPopulateEvent(data) => data,
_ => panic!("unexpected event"),
}
}
fn data_into_event(data: Self::Data) -> Event {
Event::ChunkPopulateEvent(data)
}
}
View on GitHub (pinned to 8d4639e25a)