{"record":{"id":"ba58e8cb2b1a99d5","repo":"sxyazi/yazi","slug":"offset-width-and-height-must-be-positive","errorCode":null,"errorMessage":"offset width and height must be positive: {:?}","messagePattern":"offset width and height must be positive: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-binding/src/position/offset.rs","lineNumber":32,"sourceCode":"\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":14,"sourceCodeEnd":46,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-binding/src/position/offset.rs#L14-L46","documentation":"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.","triggerScenarios":"Thrown at yazi-binding/src/position/offset.rs:32 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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."],"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-14T05:17:10.506Z"}