{"record":{"id":"0100df039a3e6b8e","repo":"Pumpkin-MC/Pumpkin","slug":"unexpected-event-0100df","errorCode":null,"errorMessage":"unexpected event","messagePattern":"unexpected event","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/pumpkin-plugin-api/src/events/world/chunk_populate.rs","lineNumber":13,"sourceCode":"use super::super::FromIntoEvent;\nuse crate::wit::pumpkin::plugin::event::{ChunkPopulateEventData, Event, EventType};\n\n/// Event triggered when a chunk is populated.\npub struct ChunkPopulateEvent;\nimpl FromIntoEvent for ChunkPopulateEvent {\n    const EVENT_TYPE: EventType = EventType::ChunkPopulateEvent;\n    type Data = ChunkPopulateEventData;\n\n    fn data_from_event(event: Event) -> Self::Data {\n        match event {\n            Event::ChunkPopulateEvent(data) => data,\n            _ => panic!(\"unexpected event\"),\n        }\n    }\n\n    fn data_into_event(data: Self::Data) -> Event {\n        Event::ChunkPopulateEvent(data)\n    }\n}\n","sourceCodeStart":1,"sourceCodeEnd":21,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin-plugin-api/src/events/world/chunk_populate.rs#L1-L21","documentation":"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.","triggerScenarios":"Delivering any other world event to a `ChunkPopulateEvent` handler, or invoking the macro-generated conversion with a mismatched `Event` in a custom harness.","commonSituations":"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.","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."],"exampleFix":"// before\nif is_chunk_event(&ev) { populate_handler(ev) } // any chunk event passes\n// after\nif matches!(ev, Event::ChunkPopulateEvent(_)) { populate_handler(ev) }","handlingStrategy":"type-guard","validationCode":"assert!(matches!(event, Event::ChunkPopulateEvent(_)), \"handler requires Event::ChunkPopulateEvent\");","typeGuard":"fn as_chunk_populate(ev: &Event) -> Option<&ChunkPopulateEventData> {\n    if let Event::ChunkPopulateEvent(d) = ev { Some(d) } else { None }\n}","tryCatchPattern":"// guard before dispatch:\nif let Event::ChunkPopulateEvent(data) = event { handle(data) } else { log::warn!(\"mismatched event at chunk-populate handler\") }","preventionTips":["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."],"tags":["rust","panic","events","plugin-api","world","chunk"],"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"}