{"record":{"id":"156363ee11d5eef3","repo":"Pumpkin-MC/Pumpkin","slug":"unexpected-event-156363","errorCode":null,"errorMessage":"unexpected event","messagePattern":"unexpected event","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/pumpkin-plugin-api/src/events/world/async_structure_generate.rs","lineNumber":13,"sourceCode":"use super::super::FromIntoEvent;\nuse crate::wit::pumpkin::plugin::event::{AsyncStructureGenerateEventData, Event, EventType};\n\n/// Event triggered when a structure is asynchronously generated.\npub struct AsyncStructureGenerateEvent;\nimpl FromIntoEvent for AsyncStructureGenerateEvent {\n    const EVENT_TYPE: EventType = EventType::AsyncStructureGenerateEvent;\n    type Data = AsyncStructureGenerateEventData;\n\n    fn data_from_event(event: Event) -> Self::Data {\n        match event {\n            Event::AsyncStructureGenerateEvent(data) => data,\n            _ => panic!(\"unexpected event\"),\n        }\n    }\n\n    fn data_into_event(data: Self::Data) -> Event {\n        Event::AsyncStructureGenerateEvent(data)\n    }\n}\n","sourceCodeStart":1,"sourceCodeEnd":21,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin-plugin-api/src/events/world/async_structure_generate.rs#L1-L21","documentation":"This panic fires inside `FromIntoEvent::data_from_event` for `AsyncStructureGenerateEvent` when the passed `Event` is not `Event::AsyncStructureGenerateEvent`. The macro-generated plugin method pipeline uses this conversion to unwrap typed data after `EVENT_TYPE`-based routing, so a foreign variant signals a misrouted or hand-constructed event and aborts the plugin thread.","triggerScenarios":"Routing any other world event (e.g. `Event::ChunkLoadEvent`) to an `AsyncStructureGenerateEvent` handler, or calling the conversion directly with a mismatched `Event` in a custom harness.","commonSituations":"Custom event buses whose routing key disagrees with the payload; plugin compiled against a different `Event` enum than the host (WIT/version skew); tests reusing events across handlers.","solutions":["Fix the host dispatcher so handlers receive only events matching their `EVENT_TYPE`.","Rebuild plugin and host from the same pumpkin-plugin-api/WIT revision.","Construct `Event::AsyncStructureGenerateEvent(data)` before invoking the handler in custom code.","Verify registration macros map each handler to exactly one `EventType`."],"exampleFix":"// before\nEvent::AsyncStructureGenerateEvent(data) => data,\n_ => panic!(\"unexpected event\"),\n// after (harness guard)\nEvent::AsyncStructureGenerateEvent(data) => data,\nother => unreachable!(\"AsyncStructureGenerate handler got {:?}\", other.event_type()),","handlingStrategy":"type-guard","validationCode":"assert!(matches!(event, Event::AsyncStructureGenerateEvent(_)), \"handler requires Event::AsyncStructureGenerateEvent\");","typeGuard":"fn as_async_structure_generate(ev: &Event) -> Option<&AsyncStructureGenerateEventData> {\n    if let Event::AsyncStructureGenerateEvent(d) = ev { Some(d) } else { None }\n}","tryCatchPattern":"// guard before invoking macro-generated handler:\nif let Event::AsyncStructureGenerateEvent(data) = event { handle(data) } else { log::warn!(\"foreign event at structure-generate handler\") }","preventionTips":["Confirm the macro-generated registration uses the correct `EventType` per handler.","Rebuild plugin and host together after any pumpkin-plugin-api update.","Do not construct `Event` variants by hand in dispatch code.","Add integration tests covering each world event handler."],"tags":["rust","panic","events","plugin-api","world"],"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"}