sxyazi/yazi · error
offset width and height must be positive: {:?}
Error message
offset width and height must be positive: {:?} What it means
Validation in `TryFrom<[i16; 4]> for Offset`: `values[2]` (width) or `values[3]` (height) is negative. Since the fields are unsigned (`u16`) in the resulting Offset, negative dimensions cannot be represented and are rejected upfront.
Source
Thrown at yazi-binding/src/position/offset.rs:32
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
- Use non-negative width and height values in the offset array.
- Clamp negative values to 0 before constructing an Offset if the source data may be negative.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at yazi-binding/src/position/offset.rs:32 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/ba58e8cb2b1a99d5.
Report an issue: GitHub.