sxyazi/yazi · error

offset must have 4 values: {:?}

Error message

offset must have 4 values: {:?}

What it means

Length check in `TryFrom<[i16; 4]> for Offset`: the input is a fixed-size array of four i16s, so the length is always 4 and this branch is effectively unreachable; it exists as a defensive guard for callers constructing the offset generically. If it ever fires, the input array was not a valid 4-tuple offset.

Source

Thrown at yazi-binding/src/position/offset.rs:29

}

impl From<ratatui_core::layout::Rect> for Offset {
	fn from(value: ratatui_core::layout::Rect) -> Self {
		Self {
			x:      value.x as i16,
			y:      value.y as i16,
			width:  value.width,
			height: value.height,
		}
	}
}

impl TryFrom<[i16; 4]> for Offset {
	type Error = anyhow::Error;

	fn try_from(values: [i16; 4]) -> Result<Self, Self::Error> {
		if values.len() != 4 {
			bail!("offset must have 4 values: {:?}", values);
		}
		if values[2] < 0 || values[3] < 0 {
			bail!("offset width and height must be positive: {:?}", values);
		}
		if values[3] < 3 {
			bail!("offset height must be at least 3: {:?}", values);
		}

		Ok(Self {
			x:      values[0],
			y:      values[1],
			width:  values[2] as u16,
			height: values[3] as u16,
		})
	}
}

View on GitHub (pinned to 5f901b886b)

Solutions

  1. Pass exactly four integers (x, y, width, height) when constructing an Offset.
  2. At Lua/plugin boundaries, validate table length before converting to `[i16; 4]`.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at yazi-binding/src/position/offset.rs:29 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of sxyazi/yazi@5f901b886b (2026-09-02). Data as JSON: /api/errors/196dfb3d6776006d. Report an issue: GitHub.