{"record":{"id":"2b88ca4dbf592033","repo":"sxyazi/yazi","slug":"invalid-layout-ratio","errorCode":null,"errorMessage":"invalid layout ratio: {:?}","messagePattern":"invalid layout ratio: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-config/src/mgr/ratio.rs","lineNumber":20,"sourceCode":"use mlua::{ExternalError, FromLua, IntoLua, Lua, MetaMethod, Table, UserData, UserDataMethods, Value};\nuse serde::{Deserialize, Serialize};\nuse yazi_binding::deprecate;\n\n#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]\n#[serde(try_from = \"[u16; 3]\")]\npub struct MgrRatio {\n\tparent:  u16,\n\tcurrent: u16,\n\tpreview: u16,\n\tall:     u16,\n}\n\nimpl TryFrom<[u16; 3]> for MgrRatio {\n\ttype Error = anyhow::Error;\n\n\tfn try_from(ratio: [u16; 3]) -> Result<Self, Self::Error> {\n\t\tif ratio.len() != 3 {\n\t\t\tbail!(\"invalid layout ratio: {:?}\", ratio);\n\t\t}\n\t\tif ratio.iter().all(|&r| r == 0) {\n\t\t\tbail!(\"at least one layout ratio must be non-zero: {:?}\", ratio);\n\t\t}\n\n\t\tOk(Self {\n\t\t\tparent:  ratio[0],\n\t\t\tcurrent: ratio[1],\n\t\t\tpreview: ratio[2],\n\t\t\tall:     ratio[0] + ratio[1] + ratio[2],\n\t\t})\n\t}\n}\n\n// TODO: remove ---\nimpl MgrRatio {\n\tfn at(self, idx: usize) -> Option<u16> {\n\t\tmatch idx {","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-config/src/mgr/ratio.rs#L2-L38","documentation":"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.","triggerScenarios":"Thrown at yazi-config/src/mgr/ratio.rs:20 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5f901b886b14de1f17460b6e52e9de5d67f8aba9","analyzedAt":"2026-09-02T18:38:25.566Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}