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

Unspecified ResizeType

Error message

Unspecified ResizeType

What it means

Intended to be returned by proto_i32_to_resize for ResizeType::Unspecified, but in the current code it is unreachable: the first match already routes any value other than Increase/Decrease (including Unspecified = 0) to 'Invalid ResizeType'. You will practically see 'Invalid ResizeType: 0' instead of this message.

Source

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

        crate::data::UnblockCondition::OnExitSuccess => ProtoUnblockCondition::OnExitSuccess as i32,
        crate::data::UnblockCondition::OnExitFailure => ProtoUnblockCondition::OnExitFailure as i32,
        crate::data::UnblockCondition::OnAnyExit => ProtoUnblockCondition::OnAnyExit as i32,
    }
}

// Reverse helper functions for Action conversion

fn proto_i32_to_resize(resize: i32) -> Result<crate::data::Resize> {
    use crate::client_server_contract::client_server_contract::ResizeType as ProtoResize;
    let proto_resize = match resize {
        x if x == ProtoResize::Increase as i32 => ProtoResize::Increase,
        x if x == ProtoResize::Decrease as i32 => ProtoResize::Decrease,
        _ => return Err(anyhow!("Invalid ResizeType: {}", resize)),
    };
    match proto_resize {
        ProtoResize::Increase => Ok(crate::data::Resize::Increase),
        ProtoResize::Decrease => Ok(crate::data::Resize::Decrease),
        ProtoResize::Unspecified => Err(anyhow!("Unspecified ResizeType")),
    }
}

fn proto_i32_to_direction(direction: i32) -> Result<crate::data::Direction> {
    use crate::client_server_contract::client_server_contract::Direction as ProtoDirection;
    let proto_direction = match direction {
        x if x == ProtoDirection::Left as i32 => ProtoDirection::Left,
        x if x == ProtoDirection::Right as i32 => ProtoDirection::Right,
        x if x == ProtoDirection::Up as i32 => ProtoDirection::Up,
        x if x == ProtoDirection::Down as i32 => ProtoDirection::Down,
        _ => return Err(anyhow!("Invalid Direction: {}", direction)),
    };
    match proto_direction {
        ProtoDirection::Left => Ok(crate::data::Direction::Left),
        ProtoDirection::Right => Ok(crate::data::Direction::Right),
        ProtoDirection::Up => Ok(crate::data::Direction::Up),
        ProtoDirection::Down => Ok(crate::data::Direction::Down),
        ProtoDirection::Unspecified => Err(anyhow!("Unspecified direction")),

View on GitHub (pinned to 98a0837077)

Solutions

  1. When you see 'Invalid ResizeType: 0' in logs, treat it as an unset resize field and fix the sender
  2. Merge the two matches into one so Unspecified is handled in a single place, eliminating the dead arm
  3. Add a test covering all ResizeType values to keep the conversion exhaustive

Example fix

// before (two matches, dead Unspecified arm)
let proto_resize = match resize { ... _ => return Err(anyhow!("Invalid ResizeType: {}", resize)) };
match proto_resize { ..., ProtoResize::Unspecified => Err(anyhow!("Unspecified ResizeType")) }

// after (single exhaustive match)
let proto_resize = ProtoResize::try_from(resize).context("Invalid ResizeType")?;
Defensive patterns

Strategy: validation

Validate before calling

// Guard against the whole class (unset OR invalid) before converting:
fn resize_field_ok(v: i32) -> bool {
    v == ProtoResize::Increase as i32 || v == ProtoResize::Decrease as i32
}

Prevention

When it happens

Trigger: Only reachable if the first match were extended to accept Unspecified; today no input reaches this arm. The equivalent real-world trigger is an unset resize field, which produces error 122 with value 0.

Common situations: Grep-driven debugging where this string appears in search results but never in logs; contributors adding a variant to the first match without updating the second.

Related errors


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