Pumpkin-MC/Pumpkin · error
unexpected event
Error message
unexpected event
What it means
This panic fires inside `FromIntoEvent::data_from_event` for `ChunkLoadEvent` when the passed `Event` is not `Event::ChunkLoadEvent`. This impl unwraps the chunk-load payload after the plugin macro pipeline routes by `EVENT_TYPE`; any other variant means events were crossed or the enum was built manually, breaking the routing invariant and panicking.
Solutions
- Fix the dispatcher so chunk-load handlers receive only `Event::ChunkLoadEvent`.
- Rebuild both plugin and host against the same API/WIT version.
- Construct `Event::ChunkLoadEvent(data)` before invoking the handler in a harness.
- Test each chunk event type round-trips through `data_into_event`/`data_from_event`.
Example fix
// before
Event::ChunkLoadEvent(data) => data,
_ => panic!("unexpected event"),
// after (diagnostic)
Event::ChunkLoadEvent(data) => data,
other => unreachable!("ChunkLoad handler received non-chunk-load event"), Defensive patterns
Strategy: type-guard
Validate before calling
assert!(matches!(event, Event::ChunkLoadEvent(_)), "handler requires Event::ChunkLoadEvent");
Type guard
fn as_chunk_load(ev: &Event) -> Option<&ChunkLoadEventData> {
if let Event::ChunkLoadEvent(d) = ev { Some(d) } else { None }
} Try / catch
// guard before dispatch:
if let Event::ChunkLoadEvent(data) = event { handle(data) } else { log::warn!("non-load event reached chunk-load handler") } Prevention
- Double-check chunk handler registrations (load vs save vs populate are easily swapped).
- Rebuild all dependent crates after WIT/`Event` enum changes.
- Route by `event_type()` before calling handlers.
- Add round-trip unit tests for chunk event conversions.
When it happens
Trigger: Sending e.g. `Event::ChunkSaveEvent` to a `ChunkLoadEvent` handler, or calling the generated conversion directly with a mismatched `Event` in custom dispatch code.
Common situations: Custom plugin hosts mapping `EventType::ChunkLoadEvent` to the wrong event; version skew between plugin and host `Event` enums; copy-paste errors registering chunk 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/488805fe935d3894.
Report an issue: GitHub.
Appendix: source
Thrown at crates/pumpkin-plugin-api/src/events/world/chunk_load.rs:15
use crate::wit::pumpkin::plugin::event::{ChunkLoadEventData, Event, EventType};
use super::super::FromIntoEvent;
/// An event that occurs when a chunk is loaded in a world.
pub struct ChunkLoadEvent;
impl FromIntoEvent for ChunkLoadEvent {
const EVENT_TYPE: EventType = EventType::ChunkLoadEvent;
type Data = ChunkLoadEventData;
fn data_from_event(event: Event) -> Self::Data {
match event {
Event::ChunkLoadEvent(data) => data,
_ => panic!("unexpected event"),
}
}
fn data_into_event(data: Self::Data) -> Event {
Event::ChunkLoadEvent(data)
}
}
View on GitHub (pinned to 8d4639e25a)