{"record":{"id":"48a3771633b8fe50","repo":"Pumpkin-MC/Pumpkin","slug":"modifying-packets-from-wasm-is-not-yet-supported-i","errorCode":null,"errorMessage":"Modifying packets from WASM is not yet supported in this simple implementation.","messagePattern":"Modifying packets from WASM is not yet supported in this simple implementation\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/pumpkin/src/plugin/loader/wasm/wasm_host/wit/v0_1/events/server.rs","lineNumber":76,"sourceCode":"            raw_payload: self.payload.to_vec(),\n            cancelled: self.cancelled,\n        })\n    }\n\n    fn apply_wasm_event(&mut self, event: Event, state: &mut PluginHostState) {\n        cleanup_event(&event, state);\n        if let Event::PacketReceivedEvent(data) = event {\n            self.packet_id = data.packet_id;\n            self.payload = data.raw_payload.into();\n            self.cancelled = data.cancelled;\n        }\n    }\n    fn from_wasm_event(event: Event, _state: &mut PluginHostState) -> Self {\n        match event {\n            Event::PacketReceivedEvent(_) => {\n                // TODO: Implement converting from WIT variant back to raw if needed.\n                // For now, we only support cancellation.\n                panic!(\n                    \"Modifying packets from WASM is not yet supported in this simple implementation.\"\n                );\n            }\n            _ => panic!(\"unexpected event type\"),\n        }\n    }\n}\n\nimpl ToFromWasmEvent for PacketSentEvent {\n    fn to_wasm_event(&self, state: &mut PluginHostState) -> Event {\n        let player_res = state\n            .add_player(self.player.clone())\n            .expect(\"failed to add player resource\");\n\n        let packet = match self.player.client.as_ref() {\n            ClientPlatform::Java(_) => {\n                generated_packets::clientbound_java_any_to_wit(self.packet.as_ref())\n                    .map_or(ClientboundPacket::Unknown, ClientboundPacket::Java)","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin/src/plugin/loader/wasm/wasm_host/wit/v0_1/events/server.rs#L58-L94","documentation":"PacketReceivedEvent::from_wasm_event intentionally panics: converting a WIT packet event back into the raw host event is not implemented, because WASM plugins may only cancel packets, not modify them. Reaching this arm means the host tried to apply a modified event returned by a plugin, which this simple implementation does not support.","triggerScenarios":"A WASM plugin receives a PacketReceivedEvent and the host attempts to call from_wasm_event to convert the (possibly modified) event back — i.e. any code path that reads back packet contents from the plugin rather than only its cancelled flag.","commonSituations":"Plugin API or host code attempts to apply plugin-side packet modifications; a developer extended the event pipeline to support mutation before the converter was implemented.","solutions":["Only read the cancelled flag from the plugin's returned event; never convert the full packet back via from_wasm_event.","If packet modification is needed, implement the WIT-variant-to-raw conversion marked by the TODO in server.rs.","Keep plugin handlers to cancel-only semantics for packet events until upstream support lands.","Track upstream Pumpkin work adding packet modification support for WASM plugins."],"exampleFix":"// before\nlet converted = PacketReceivedEvent::from_wasm_event(wasm_event, state);\n// after\nlet cancelled = match wasm_event {\n    Event::PacketReceivedEvent(d) => d.cancelled,\n    _ => false,\n}; // only consume the cancel flag","handlingStrategy":"fallback","validationCode":"// only convert when you just need the cancel flag\nif !matches!(wasm_event, Event::PacketReceivedEvent(_)) { skip(); }","typeGuard":"fn packet_event_is_cancel_only(e: &Event) -> Option<bool> {\n    match e { Event::PacketReceivedEvent(d) => Some(d.cancelled), _ => None }\n}","tryCatchPattern":"let cancelled = catch_unwind(|| PacketReceivedEvent::from_wasm_event(event, state))\n    .ok()\n    .map(|e| e.cancelled)\n    .unwrap_or(false);","preventionTips":["Treat WASM packet events as cancel-only; never read back packet data","Implement the TODO conversion in server.rs before enabling modification","Gate any packet-mutation feature behind a supported converter","Track upstream Pumpkin support for WASM packet modification"],"tags":["wasm","plugin","unsupported-operation","packets"],"backgroundTag":"unsupported-operation","analyzedSha":"8d4639e25a57c15e47448ec327c780d41bbf2356","analyzedAt":"2026-09-09T15:32:22.916Z","contentChangedAt":"2026-09-09T15:32:22.916Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}