{"record":{"id":"c4c866ad43012253","repo":"Pumpkin-MC/Pumpkin","slug":"unexpected-event-c4c866","errorCode":null,"errorMessage":"unexpected event","messagePattern":"unexpected event","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/pumpkin-plugin-api/src/events/inventory/brewing_stand_fuel.rs","lineNumber":13,"sourceCode":"use super::super::FromIntoEvent;\nuse crate::wit::pumpkin::plugin::event::{BrewingStandFuelEventData, Event, EventType};\n\n/// Event triggered when brewing stand fuel is consumed or refilled.\npub struct BrewingStandFuelEvent;\nimpl FromIntoEvent for BrewingStandFuelEvent {\n    const EVENT_TYPE: EventType = EventType::BrewingStandFuelEvent;\n    type Data = BrewingStandFuelEventData;\n\n    fn data_from_event(event: Event) -> Self::Data {\n        match event {\n            Event::BrewingStandFuelEvent(data) => data,\n            _ => panic!(\"unexpected event\"),\n        }\n    }\n\n    fn data_into_event(data: Self::Data) -> Event {\n        Event::BrewingStandFuelEvent(data)\n    }\n}\n","sourceCodeStart":1,"sourceCodeEnd":21,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin-plugin-api/src/events/inventory/brewing_stand_fuel.rs#L1-L21","documentation":"This panic fires in `data_from_event`, the `Event` trait implementation for `BrewingStandFuelEvent`. It only accepts `Event::BrewingStandFuelEvent(data)`; any other `Event` variant means the dispatcher delivered a mismatched payload. The library treats that as an invariant violation and panics with \"unexpected event\".","triggerScenarios":"Calling `data_from_event` with an `Event` that is not `Event::BrewingStandFuelEvent`, such as a brewing/furnace event routed to this handler or an incorrect `EventType` registration.","commonSituations":"Handler registered under the wrong `EventType` in a config/registration table, custom event routing code, or `Event` enum drift after upgrading pumpkin-plugin-api so previously matched routes now fall to the `_` arm.","solutions":["Register the handler for `EventType::BrewingStandFuelEvent` and confirm the dispatcher keys off that type.","Construct events through `BrewingStandFuelEvent::data_into_event` when calling manually.","Align API versions across server and plugin; clean rebuild to eliminate variant mismatch.","Narrow first: `if let Event::BrewingStandFuelEvent(data) = event { ... }`.","Replace the panic with a logged error or typed `Result` for graceful failure."],"exampleFix":"// before\nmatch event {\n    Event::BrewingStandFuelEvent(data) => data,\n    _ => panic!(\"unexpected event\"),\n}\n// after\nmatch event {\n    Event::BrewingStandFuelEvent(data) => data,\n    _ => return None,\n}","handlingStrategy":"type-guard","validationCode":"// Before dispatch\nassert_eq!(event.event_type(), EventType::BrewingStandFuelEvent, \"wrong event routed to BrewingStandFuel handler\");","typeGuard":"fn as_brewing_stand_fuel(event: &Event) -> Option<&BrewingStandFuelEventData> {\n    match event {\n        Event::BrewingStandFuelEvent(data) => Some(data),\n        _ => None,\n    }\n}","tryCatchPattern":"let result = std::panic::catch_unwind(AssertUnwindSafe(|| handler.data_from_event(event)));\nif result.is_err() {\n    log::error!(\"BrewingStandFuelEvent handler received an unexpected event variant\");\n}","preventionTips":["Register the handler under EventType::BrewingStandFuelEvent only.","Narrow the event with if-let/matches! before manual extraction.","Construct events via BrewingStandFuelEvent::data_into_event.","Keep API versions aligned between server and plugin.","Verify EventType constants in registration code — nearby names like BrewEvent are easy to mistype."],"tags":["rust","panic","event-dispatch","inventory"],"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"}