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

Unspecified direction

Error message

Unspecified direction

What it means

Intended for Direction::Unspecified in proto_i32_to_direction, but unreachable in the current code: the first match routes Unspecified (0) to the 'Invalid Direction: 0' arm. The message exists only as a guard in the second match, which can only receive Left/Right/Up/Down.

Source

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

        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")),
    }
}

fn proto_i32_to_search_direction(direction: i32) -> Result<crate::input::actions::SearchDirection> {
    use crate::client_server_contract::client_server_contract::SearchDirection as ProtoSearchDirection;
    let proto_direction = match direction {
        x if x == ProtoSearchDirection::Up as i32 => ProtoSearchDirection::Up,
        x if x == ProtoSearchDirection::Down as i32 => ProtoSearchDirection::Down,
        _ => return Err(anyhow!("Invalid SearchDirection: {}", direction)),
    };
    match proto_direction {
        ProtoSearchDirection::Up => Ok(crate::input::actions::SearchDirection::Up),
        ProtoSearchDirection::Down => Ok(crate::input::actions::SearchDirection::Down),
        ProtoSearchDirection::Unspecified => Err(anyhow!("Unspecified search direction")),
    }
}

fn proto_i32_to_search_option(option: i32) -> Result<crate::input::actions::SearchOption> {

View on GitHub (pinned to 98a0837077)

Solutions

  1. Diagnose the real symptom as an unset/zero direction field on the sender
  2. Consolidate the two-stage match into one exhaustive conversion so this cannot drift
  3. Keep a unit test that round-trips every Direction value through the proto conversion

Example fix

// before
match proto_direction { ..., ProtoDirection::Unspecified => Err(anyhow!("Unspecified direction")) }

// after
match direction {
    x if x == ProtoDirection::Left as i32 => Ok(crate::data::Direction::Left),
    x if x == ProtoDirection::Right as i32 => Ok(crate::data::Direction::Right),
    x if x == ProtoDirection::Up as i32 => Ok(crate::data::Direction::Up),
    x if x == ProtoDirection::Down as i32 => Ok(crate::data::Direction::Down),
    other => Err(anyhow!("Invalid or unspecified Direction: {}", other)),
}
Defensive patterns

Strategy: validation

Validate before calling

// An unset direction shows up as 'Invalid Direction: 0'; guard before convert:
fn direction_is_set_and_valid(v: i32) -> bool {
    v != 0 && direction_value_is_valid(v)
}

Prevention

When it happens

Trigger: Not reachable through normal execution; the observable failure for an unset direction is 'Invalid Direction: 0' (error 124). Becomes reachable only if the first match is later widened to map 0 to Unspecified.

Common situations: Searching the codebase for this string during debugging; refactors that touch one match but not the other.

Related errors


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