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

Missing new_size

Error message

Missing new_size

What it means

Thrown while converting a ClientToServerMsg::TerminalResize frame (zellij-utils/src/ipc/protobuf_conversion.rs): the TerminalResize wrapper arrived but its nested new_size field (the dimensions tuple) was None. Like [78], a singular message-typed proto field has no default instance, so an unset new_size cannot be converted and the error names the missing field.

Source

Thrown at zellij-utils/src/ipc/protobuf_conversion.rs:238

            Some(client_to_server_msg::Message::ForegroundColor(fg_color)) => {
                Ok(ClientToServerMsg::ForegroundColor {
                    color: fg_color.color,
                })
            },
            Some(client_to_server_msg::Message::ColorRegisters(color_regs)) => {
                Ok(ClientToServerMsg::ColorRegisters {
                    color_registers: color_regs
                        .color_registers
                        .into_iter()
                        .map(|cr| cr.try_into())
                        .collect::<Result<Vec<_>>>()?,
                })
            },
            Some(client_to_server_msg::Message::TerminalResize(resize)) => {
                Ok(ClientToServerMsg::TerminalResize {
                    new_size: resize
                        .new_size
                        .ok_or_else(|| anyhow!("Missing new_size"))?
                        .try_into()?,
                })
            },
            Some(client_to_server_msg::Message::FirstClientConnected(first_client)) => {
                Ok(ClientToServerMsg::FirstClientConnected {
                    cli_assets: first_client
                        .cli_assets
                        .ok_or_else(|| anyhow!("Missing cli_assets"))?
                        .try_into()?,
                    is_web_client: first_client.is_web_client,
                })
            },
            Some(client_to_server_msg::Message::AttachClient(attach)) => {
                Ok(ClientToServerMsg::AttachClient {
                    cli_assets: attach
                        .cli_assets
                        .ok_or_else(|| anyhow!("Missing cli_assets"))?
                        .try_into()?,

View on GitHub (pinned to e839bfffa5)

Solutions

  1. Set new_size (columns/rows) whenever sending TerminalResize; it is the entire payload of that variant.
  2. Keep client and server zellij versions aligned so field semantics match.
  3. Validate inbound frames (new_size.is_some()) and ignore/log malformed ones instead of failing the whole conversion loop.

Example fix

// before
let msg = client_to_server_msg::Message::TerminalResize(TerminalResize::default());

// after
let msg = client_to_server_msg::Message::TerminalResize(TerminalResize {
    new_size: Some(Resize { columns: 120, rows: 40 }),
});
Defensive patterns

Strategy: validation

Validate before calling

// receiver side: reject resize frames without a size
let Some(new_size) = resize.new_size else {
    log::warn!("TerminalResize without new_size; ignored");
    return Ok(None);
};

Type guard

fn has_new_size(m: &TerminalResize) -> bool {
    m.new_size.is_some()
}

Try / catch

match ClientToServerMsg::try_from(proto_msg) {
    Ok(msg) => Some(msg),
    Err(e) if e.to_string().contains("Missing new_size") => {
        log::warn!("peer sent resize frame without size; frame ignored");
        None
    },
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: A client emits the TerminalResize oneof variant without filling new_size — handcrafted IPC clients, downgrade/skew where the field is dropped, or default-constructed test messages passed to TryFrom<ClientToServerMsg>.

Common situations: Custom clients learning the resize message shape; older clients against newer servers; integration tests with Default::default() frames.

Related errors


AI-assisted analysis of zellij-org/zellij@e839bfffa5 (2026-08-19). Data as JSON: /api/errors/96d2b1cad921ea3c. Report an issue: GitHub.