{"record":{"id":"2de2190ce267d9c1","repo":"zellij-org/zellij","slug":"invalid-direction","errorCode":null,"errorMessage":"Invalid Direction: {}","messagePattern":"Invalid Direction: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"zellij-utils/src/ipc/protobuf_conversion.rs","lineNumber":3502,"sourceCode":"        x if x == ProtoResize::Increase as i32 => ProtoResize::Increase,\n        x if x == ProtoResize::Decrease as i32 => ProtoResize::Decrease,\n        _ => return Err(anyhow!(\"Invalid ResizeType: {}\", resize)),\n    };\n    match proto_resize {\n        ProtoResize::Increase => Ok(crate::data::Resize::Increase),\n        ProtoResize::Decrease => Ok(crate::data::Resize::Decrease),\n        ProtoResize::Unspecified => Err(anyhow!(\"Unspecified ResizeType\")),\n    }\n}\n\nfn proto_i32_to_direction(direction: i32) -> Result<crate::data::Direction> {\n    use crate::client_server_contract::client_server_contract::Direction as ProtoDirection;\n    let proto_direction = match direction {\n        x if x == ProtoDirection::Left as i32 => ProtoDirection::Left,\n        x if x == ProtoDirection::Right as i32 => ProtoDirection::Right,\n        x if x == ProtoDirection::Up as i32 => ProtoDirection::Up,\n        x if x == ProtoDirection::Down as i32 => ProtoDirection::Down,\n        _ => return Err(anyhow!(\"Invalid Direction: {}\", direction)),\n    };\n    match proto_direction {\n        ProtoDirection::Left => Ok(crate::data::Direction::Left),\n        ProtoDirection::Right => Ok(crate::data::Direction::Right),\n        ProtoDirection::Up => Ok(crate::data::Direction::Up),\n        ProtoDirection::Down => Ok(crate::data::Direction::Down),\n        ProtoDirection::Unspecified => Err(anyhow!(\"Unspecified direction\")),\n    }\n}\n\nfn proto_i32_to_search_direction(direction: i32) -> Result<crate::input::actions::SearchDirection> {\n    use crate::client_server_contract::client_server_contract::SearchDirection as ProtoSearchDirection;\n    let proto_direction = match direction {\n        x if x == ProtoSearchDirection::Up as i32 => ProtoSearchDirection::Up,\n        x if x == ProtoSearchDirection::Down as i32 => ProtoSearchDirection::Down,\n        _ => return Err(anyhow!(\"Invalid SearchDirection: {}\", direction)),\n    };\n    match proto_direction {","sourceCodeStart":3484,"sourceCodeEnd":3520,"githubUrl":"https://github.com/zellij-org/zellij/blob/98a0837077492d53dd252ab30bc3e43e41e504f4/zellij-utils/src/ipc/protobuf_conversion.rs#L3484-L3520","documentation":"Returned by proto_i32_to_direction when the i32 does not match any of the four known Direction values (Left/Right/Up/Down). It covers both corrupted out-of-range integers and the proto3 unset value, since Unspecified = 0 falls into the wildcard arm here too.","triggerScenarios":"Decoding an Action carrying a direction field that was never set (0) or holds an unknown integer — e.g. Move/Resize actions from a mismatched client version or a malformed IPC message.","commonSituations":"Client/server version skew; external tooling or plugins constructing protobuf actions without setting direction; partially initialized messages in tests.","solutions":["Set the direction field explicitly on the sending side before serializing","Run the same zellij version on both sides of the connection","Pre-validate the integer against the known variant values before converting"],"exampleFix":"// before\nlet dir = proto_i32_to_direction(action.direction)?;\n\n// after\nlet dir = proto_i32_to_direction(action.direction)\n    .context(\"direction field missing or invalid in Action\")?;","handlingStrategy":"validation","validationCode":"use crate::client_server_contract::client_server_contract::Direction as ProtoDirection;\nfn direction_value_is_valid(v: i32) -> bool {\n    v == ProtoDirection::Left as i32 || v == ProtoDirection::Right as i32\n        || v == ProtoDirection::Up as i32 || v == ProtoDirection::Down as i32\n}","typeGuard":"fn is_valid_direction(v: i32) -> bool {\n    direction_value_is_valid(v)\n}","tryCatchPattern":"let dir = proto_i32_to_direction(action.direction)\n    .map_err(|e| e.context(format!(\"invalid direction field {}\", action.direction)))?;","preventionTips":["Set direction explicitly whenever serializing Move/Resize actions","Deploy matched versions on both IPC ends","Validate untrusted protobuf input before converting to internal enums"],"tags":["protobuf","ipc","direction","enum-decode"],"backgroundTag":null,"analyzedSha":"98a0837077492d53dd252ab30bc3e43e41e504f4","analyzedAt":"2026-08-16T13:02:01.396Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}