sxyazi/yazi · error
invalid layout ratio: {:?}
Error message
invalid layout ratio: {:?} What it means
Layout-ratio guard in `TryFrom<[u16; 3]> for MgrRatio`: a length check on a fixed-size three-element array, so it is effectively unreachable (the length is always 3) and exists only as a defensive check. If it ever fired, the input triple was not a valid parent/current/preview ratio.
Source
Thrown at yazi-config/src/mgr/ratio.rs:20
use mlua::{ExternalError, FromLua, IntoLua, Lua, MetaMethod, Table, UserData, UserDataMethods, Value};
use serde::{Deserialize, Serialize};
use yazi_binding::deprecate;
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
#[serde(try_from = "[u16; 3]")]
pub struct MgrRatio {
parent: u16,
current: u16,
preview: u16,
all: u16,
}
impl TryFrom<[u16; 3]> for MgrRatio {
type Error = anyhow::Error;
fn try_from(ratio: [u16; 3]) -> Result<Self, Self::Error> {
if ratio.len() != 3 {
bail!("invalid layout ratio: {:?}", ratio);
}
if ratio.iter().all(|&r| r == 0) {
bail!("at least one layout ratio must be non-zero: {:?}", ratio);
}
Ok(Self {
parent: ratio[0],
current: ratio[1],
preview: ratio[2],
all: ratio[0] + ratio[1] + ratio[2],
})
}
}
// TODO: remove ---
impl MgrRatio {
fn at(self, idx: usize) -> Option<u16> {
match idx {View on GitHub (pinned to 5f901b886b)
Solutions
- Provide exactly three numbers for `[mgr] ratio`, e.g. `ratio = [1, 2, 3]`.
- Validate the ratio array length in config/tooling before it reaches this type.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at yazi-config/src/mgr/ratio.rs:20 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/2b88ca4dbf592033.
Report an issue: GitHub.