{"record":{"id":"1c90de847b69328a","repo":"zellij-org/zellij","slug":"failed-to-convert-to-protobuf-1c90de","errorCode":null,"errorMessage":"Failed to convert to protobuf: {:?}","messagePattern":"Failed to convert to protobuf: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"zellij-server/src/plugins/wasm_bridge.rs","lineNumber":2191,"sourceCode":"        plugin_id,\n        loading_indication,\n    ));\n}\n\npub fn apply_before_close_event_to_plugin(\n    plugin_id: PluginId,\n    client_id: ClientId,\n    running_plugin: &mut RunningPlugin,\n    senders: ThreadSenders,\n) -> Result<()> {\n    let instance = &running_plugin.instance;\n\n    let err_context = || format!(\"Failed to apply event to plugin {plugin_id}\");\n    let event = Event::BeforeClose;\n    let protobuf_event: ProtobufEvent = event\n        .clone()\n        .try_into()\n        .map_err(|e| anyhow!(\"Failed to convert to protobuf: {:?}\", e))?;\n    let update = instance\n        .get_typed_func::<(), i32>(&mut running_plugin.store, \"update\")\n        .with_context(err_context)?;\n    wasi_write_object(running_plugin.store.data(), &protobuf_event.encode_to_vec())\n        .with_context(err_context)?;\n    let _should_render = update\n        .call(&mut running_plugin.store, ())\n        .with_context(err_context)?;\n    let pipes_to_block_or_unblock = pipes_to_block_or_unblock(running_plugin, None);\n    let plugin_render_asset =\n        PluginRenderAsset::new(plugin_id, client_id, vec![]).with_pipes(pipes_to_block_or_unblock);\n    let _ = senders\n        .send_to_plugin(PluginInstruction::UnblockCliPipes(vec![\n            plugin_render_asset,\n        ]))\n        .context(\"failed to unblock input pipe\");\n    Ok(())\n}","sourceCodeStart":2173,"sourceCodeEnd":2209,"githubUrl":"https://github.com/zellij-org/zellij/blob/98a0837077492d53dd252ab30bc3e43e41e504f4/zellij-server/src/plugins/wasm_bridge.rs#L2173-L2209","documentation":"In close_plugin (wasm_bridge.rs), the hardcoded Event::BeforeClose must be converted to ProtobufEvent before being written into the plugin's WASI stdin. This error means that conversion failed, so the plugin never receives its BeforeClose update during teardown.","triggerScenarios":"Effectively an internal invariant break: Event::BeforeClose gains a field that ProtobufEvent conversion rejects, or the protobuf event enum drifts out of sync with the Rust Event enum across versions. Not caused by user data.","commonSituations":"Mixed zellij/protobuf versions after a partial upgrade or stale build artifacts; contributing code that adds an Event variant without a protobuf mapping.","solutions":["Rebuild zellij from a clean tree so Event and ProtobufEvent come from the same source version","If you are developing zellij itself, implement/derive the TryFrom<Event> mapping for the new variant","Restart the session; a one-off occurrence during shutdown does not corrupt state, the plugin is unloaded anyway"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"let protobuf_event: ProtobufEvent = Event::BeforeClose.clone().try_into()\n    .with_context(|| format!(\"Failed to apply event to plugin {plugin_id}\"))?;","preventionTips":["Keep zellij-server and its generated protobuf types from the same build (clean rebuild after upgrades)"],"tags":["plugin","protobuf","event","internal-invariant","shutdown"],"backgroundTag":null,"analyzedSha":"98a0837077492d53dd252ab30bc3e43e41e504f4","analyzedAt":"2026-08-16T13:02:01.396Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}