zellij-org/zellij · error · anyhow::Error

Worker name ("{}") should not be specified in message to plu

Error message

Worker name ("{}") should not be specified in message to plugin

What it means

The inverse guard of error 46: post_message_to_plugin rejects any PluginMessage that carries a worker_name. Plugin-bound messages must have worker_name None; worker-bound ones must go through the worker path.

Source

Thrown at zellij-server/src/plugins/zellij_exports.rs:2602

        ));
}

fn post_message_to(env: &PluginEnv, plugin_message: PluginMessage) -> Result<()> {
    let worker_name = plugin_message
        .worker_name
        .ok_or(anyhow!("Worker name not specified in message to worker"))?;
    env.senders
        .send_to_plugin(PluginInstruction::PostMessagesToPluginWorker(
            env.plugin_id,
            env.client_id,
            worker_name,
            vec![(plugin_message.name, plugin_message.payload)],
        ))
}

fn post_message_to_plugin(env: &PluginEnv, plugin_message: PluginMessage) -> Result<()> {
    if let Some(worker_name) = plugin_message.worker_name {
        return Err(anyhow!(
            "Worker name (\"{}\") should not be specified in message to plugin",
            worker_name
        ));
    }
    env.senders
        .send_to_plugin(PluginInstruction::PostMessageToPlugin(
            env.plugin_id,
            env.client_id,
            plugin_message.name,
            plugin_message.payload,
        ))
}

fn hide_self(env: &PluginEnv) -> Result<()> {
    env.senders
        .send_to_screen(ScreenInstruction::SuppressPane(
            PaneId::Plugin(env.plugin_id),
            env.client_id,

View on GitHub (pinned to 98a0837077)

Solutions

  1. Clear worker_name (set it to None) before routing a message to a plugin
  2. Split into two constructors: one for worker messages, one for plugin messages, so the field cannot be set on the wrong path
  3. Route messages that legitimately have a worker_name through post_message_to instead

Example fix

// before
let msg = PluginMessage { name: "evt".into(), payload, worker_name: Some("w".into()) };
post_message_to_plugin(&env, msg)?; // Err

// after
let msg = PluginMessage { name: "evt".into(), payload, worker_name: None };
post_message_to_plugin(&env, msg)?;
Defensive patterns

Strategy: validation

Validate before calling

if plugin_message.worker_name.is_some() {
    return Err(anyhow!("worker_name must be None for plugin-bound messages"));
}

Type guard

fn is_plugin_message(msg: &PluginMessage) -> bool {
    msg.worker_name.is_none()
}

Prevention

When it happens

Trigger: Calling the plugin-message path with a message whose worker_name is Some(...) — usually a copy-paste of worker-message construction, or a fallback that reuses one message type for both destinations without clearing the field.

Common situations: Plugin codebases with a single `post_message` helper that sometimes targets workers; SDKs that populate worker_name eagerly for all messages.

Related errors


AI-assisted analysis of zellij-org/zellij@98a0837077 (2026-08-16). Data as JSON: /api/errors/d765b45d48ebf50f. Report an issue: GitHub.