{"record":{"id":"196dfb3d6776006d","repo":"sxyazi/yazi","slug":"offset-must-have-4-values","errorCode":null,"errorMessage":"offset must have 4 values: {:?}","messagePattern":"offset must have 4 values: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-binding/src/position/offset.rs","lineNumber":29,"sourceCode":"}\n\nimpl From<ratatui_core::layout::Rect> for Offset {\n\tfn from(value: ratatui_core::layout::Rect) -> Self {\n\t\tSelf {\n\t\t\tx:      value.x as i16,\n\t\t\ty:      value.y as i16,\n\t\t\twidth:  value.width,\n\t\t\theight: value.height,\n\t\t}\n\t}\n}\n\nimpl TryFrom<[i16; 4]> for Offset {\n\ttype Error = anyhow::Error;\n\n\tfn try_from(values: [i16; 4]) -> Result<Self, Self::Error> {\n\t\tif values.len() != 4 {\n\t\t\tbail!(\"offset must have 4 values: {:?}\", values);\n\t\t}\n\t\tif values[2] < 0 || values[3] < 0 {\n\t\t\tbail!(\"offset width and height must be positive: {:?}\", values);\n\t\t}\n\t\tif values[3] < 3 {\n\t\t\tbail!(\"offset height must be at least 3: {:?}\", values);\n\t\t}\n\n\t\tOk(Self {\n\t\t\tx:      values[0],\n\t\t\ty:      values[1],\n\t\t\twidth:  values[2] as u16,\n\t\t\theight: values[3] as u16,\n\t\t})\n\t}\n}\n","sourceCodeStart":11,"sourceCodeEnd":46,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-binding/src/position/offset.rs#L11-L46","documentation":"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.","triggerScenarios":"Thrown at yazi-binding/src/position/offset.rs:29 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass exactly four integers (x, y, width, height) when constructing an Offset.","At Lua/plugin boundaries, validate table length before converting to `[i16; 4]`."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5f901b886b14de1f17460b6e52e9de5d67f8aba9","analyzedAt":"2026-09-02T18:38:25.566Z","contentChangedAt":"2026-09-02T18:38:25.566Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}