Pumpkin-MC/Pumpkin · error

Modifying packets from WASM is not yet supported.

Error message

Modifying packets from WASM is not yet supported.

What it means

PacketSentEvent::from_wasm_event intentionally panics for Event::PacketSentEvent: converting a plugin-returned packet-sent event back to the host representation is not implemented. WASM plugins may only cancel these events, not modify the packet. Reaching this arm means the host tried to apply plugin-side modifications.

Solutions

  1. Only read the cancelled flag from the plugin's returned event; do not call from_wasm_event on packet events.
  2. Implement the missing WIT-to-raw conversion in server.rs if packet modification support is required.
  3. Restrict plugin handlers to cancel-only semantics for PacketSentEvent until support exists.
  4. Follow upstream Pumpkin development for WASM packet modification support.

Example fix

// before
let converted = PacketSentEvent::from_wasm_event(wasm_event, state);
// after
let cancelled = match wasm_event {
    Event::PacketSentEvent(d) => d.cancelled,
    _ => false,
}; // cancel-only
Defensive patterns

Strategy: fallback

Validate before calling

// only convert when you just need the cancel flag
if !matches!(wasm_event, Event::PacketSentEvent(_)) { skip(); }

Type guard

fn packet_sent_cancel_flag(e: &Event) -> Option<bool> {
    match e { Event::PacketSentEvent(d) => Some(d.cancelled), _ => None }
}

Try / catch

let cancelled = catch_unwind(|| PacketSentEvent::from_wasm_event(event, state))
    .ok()
    .map(|e| e.cancelled)
    .unwrap_or(false);

Prevention

When it happens

Trigger: The host calls from_wasm_event on a PacketSentEvent returned by a plugin — i.e. any pipeline step that attempts to convert the full WIT packet event back instead of just reading the cancelled flag.

Common situations: Host or plugin code tries to mutate outbound packets from WASM; developer extended the event pipeline to support modification before implementing the converter.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of Pumpkin-MC/Pumpkin@8d4639e25a (2026-09-09). Data as JSON: /api/errors/85cd7963a7c494c5. Report an issue: GitHub.

Appendix: source

Thrown at crates/pumpkin/src/plugin/loader/wasm/wasm_host/wit/v0_1/events/server.rs:121

            player: player_res,
            packet,
            packet_id: self.packet_id,
            raw_payload: self.payload.iter().copied().collect(),
            cancelled: self.cancelled,
        })
    }

    fn apply_wasm_event(&mut self, event: Event, state: &mut PluginHostState) {
        cleanup_event(&event, state);
        if let Event::PacketSentEvent(data) = event {
            self.payload = data.raw_payload.into();
            self.cancelled = data.cancelled;
        }
    }
    fn from_wasm_event(event: Event, _state: &mut PluginHostState) -> Self {
        match event {
            Event::PacketSentEvent(_) => {
                panic!("Modifying packets from WASM is not yet supported.");
            }
            _ => panic!("unexpected event type"),
        }
    }
}

impl ToFromWasmEvent for ServerCommandEvent {
    fn to_wasm_event(&self, _state: &mut PluginHostState) -> Event {
        Event::ServerCommandEvent(ServerCommandEventData {
            command: self.command.clone(),
            cancelled: self.cancelled,
        })
    }

    fn from_wasm_event(event: Event, _state: &mut PluginHostState) -> Self {
        match event {
            Event::ServerCommandEvent(data) => Self {
                command: data.command,

View on GitHub (pinned to 8d4639e25a)