{"record":{"id":"488805fe935d3894","repo":"Pumpkin-MC/Pumpkin","slug":"unexpected-event-488805","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_load.rs","lineNumber":15,"sourceCode":"use crate::wit::pumpkin::plugin::event::{ChunkLoadEventData, Event, EventType};\n\nuse super::super::FromIntoEvent;\n\n/// An event that occurs when a chunk is loaded in a world.\npub struct ChunkLoadEvent;\n\nimpl FromIntoEvent for ChunkLoadEvent {\n    const EVENT_TYPE: EventType = EventType::ChunkLoadEvent;\n    type Data = ChunkLoadEventData;\n\n    fn data_from_event(event: Event) -> Self::Data {\n        match event {\n            Event::ChunkLoadEvent(data) => data,\n            _ => panic!(\"unexpected event\"),\n        }\n    }\n\n    fn data_into_event(data: Self::Data) -> Event {\n        Event::ChunkLoadEvent(data)\n    }\n}\n","sourceCodeStart":1,"sourceCodeEnd":23,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin-plugin-api/src/events/world/chunk_load.rs#L1-L23","documentation":"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.","triggerScenarios":"Sending e.g. `Event::ChunkSaveEvent` to a `ChunkLoadEvent` handler, or calling the generated conversion directly with a mismatched `Event` in custom dispatch code.","commonSituations":"Custom plugin hosts mapping `EventType::ChunkLoadEvent` to the wrong event; version skew between plugin and host `Event` enums; copy-paste errors registering chunk handlers.","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`."],"exampleFix":"// before\nEvent::ChunkLoadEvent(data) => data,\n_ => panic!(\"unexpected event\"),\n// after (diagnostic)\nEvent::ChunkLoadEvent(data) => data,\nother => unreachable!(\"ChunkLoad handler received non-chunk-load event\"),","handlingStrategy":"type-guard","validationCode":"assert!(matches!(event, Event::ChunkLoadEvent(_)), \"handler requires Event::ChunkLoadEvent\");","typeGuard":"fn as_chunk_load(ev: &Event) -> Option<&ChunkLoadEventData> {\n    if let Event::ChunkLoadEvent(d) = ev { Some(d) } else { None }\n}","tryCatchPattern":"// guard before dispatch:\nif let Event::ChunkLoadEvent(data) = event { handle(data) } else { log::warn!(\"non-load event reached chunk-load handler\") }","preventionTips":["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."],"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"}