{"record":{"id":"61cf337532e262ac","repo":"sxyazi/yazi","slug":"failed-to-parse-chafa-output","errorCode":null,"errorMessage":"failed to parse chafa output","messagePattern":"failed to parse chafa output","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-adapter/src/drivers/chafa.rs","lineNumber":51,"sourceCode":"\t\t\t.arg(format!(\"{}x{}\", max.width, max.height))\n\t\t\t.arg(path)\n\t\t\t.stdin(Stdio::null())\n\t\t\t.stdout(Stdio::piped())\n\t\t\t.stderr(Stdio::null())\n\t\t\t.kill_on_drop(true)\n\t\t\t.spawn()\n\t\t\t.map_err(|e| anyhow!(\"failed to spawn chafa: {e}\"))?;\n\n\t\tlet output = child.wait_with_output().await?;\n\t\tif !output.status.success() {\n\t\t\tbail!(\"chafa failed with status: {}\", output.status);\n\t\t} else if output.stdout.is_empty() {\n\t\t\tbail!(\"chafa returned no output\");\n\t\t}\n\n\t\tlet lines: Vec<_> = output.stdout.split(|&b| b == b'\\n').collect();\n\t\tlet Ok(Some(first)) = lines[0].to_text().map(|mut t| t.lines.pop()) else {\n\t\t\tbail!(\"failed to parse chafa output\");\n\t\t};\n\n\t\tlet area = Rect {\n\t\t\tx:      max.x,\n\t\t\ty:      max.y,\n\t\t\twidth:  first.width() as u16,\n\t\t\theight: lines.len() as u16,\n\t\t};\n\n\t\tADAPTOR.image_hide()?;\n\t\tADAPTOR.shown_store(area);\n\t\tEmulator::move_lock((max.x, max.y), |w| {\n\t\t\tfor (i, line) in lines.into_iter().enumerate() {\n\t\t\t\tw.write_all(line)?;\n\t\t\t\twrite!(w, \"{}\", MoveTo(max.x, max.y + i as u16 + 1))?;\n\t\t\t}\n\t\t\tOk(area)\n\t\t})","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-adapter/src/drivers/chafa.rs#L33-L69","documentation":"The first line of chafa's stdout could not be decoded as text (invalid UTF-8) or contained no lines after splitting, so the parser cannot extract the pixel dimensions it needs. The guard sits right after splitting stdout into lines and calling `to_text()`; the faulting input is chafa's raw output itself.","triggerScenarios":"Thrown at yazi-adapter/src/drivers/chafa.rs:51 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the chafa version in use — output format may differ from what the parser expects.","Reproduce the chafa invocation manually and inspect stdout for binary or unexpected content.","Handle a decode failure by skipping the preview instead of aborting the task."],"exampleFix":null,"handlingStrategy":"try-catch","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"}