{"record":{"id":"5ec0e0232525f463","repo":"tonhowtf/omniget","slug":"tesseract-falhou-em","errorCode":null,"errorMessage":"tesseract falhou em {}: {}","messagePattern":"tesseract falhou em (.+?): (.+?)","errorType":"exception","errorClass":"anyhow","httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/ocr.rs","lineNumber":124,"sourceCode":"    };\n    let mut out = Vec::new();\n    let total = inputs.len() as u64;\n    for (i, input) in inputs.iter().enumerate() {\n        super::report(\n            &progress,\n            \"ocr\",\n            \"progress\",\n            i as u64,\n            Some(total),\n            Some(input.clone()),\n        );\n        let o = crate::core::process::command(&bin)\n            .arg(input)\n            .args([\"stdout\", \"-l\", langs, \"--psm\", \"3\"])\n            .output()\n            .await?;\n        if !o.status.success() {\n            return Err(anyhow!(\n                \"tesseract falhou em {}: {}\",\n                input,\n                String::from_utf8_lossy(&o.stderr).trim()\n            ));\n        }\n        out.push(OcrResult {\n            path: input.clone(),\n            text: String::from_utf8_lossy(&o.stdout).trim().to_string(),\n        });\n    }\n    super::report(&progress, \"ocr\", \"done\", total, Some(total), None);\n    Ok(out)\n}\n","sourceCodeStart":106,"sourceCodeEnd":138,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/ocr.rs#L106-L138","documentation":"`ocr::run` invokes the located tesseract binary with `input stdout -l <langs> --psm 3`; if the process exits with a non-zero status, the error wraps tesseract's own stderr. This means tesseract ran but failed on this specific input or language set.","triggerScenarios":"Any `run` call (or share_file/share_url/share_text/ping/refresh path) where tesseract exits non-zero: input file is not a readable image, image format unsupported/corrupt, or a requested language code (e.g. `por`) has no traineddata installed.","commonSituations":"Requesting a language not installed (missing tesseract-lang / tesseract-ocr-por package); passing PDFs or SVGs that tesseract cannot open; passing paths with characters the shell-layer mishandles; corrupt or zero-byte image files.","solutions":["Read the embedded stderr in the message: if it says 'Failed to find requested language data', install the language pack (e.g. `brew install tesseract-lang`, `apt install tesseract-ocr-<lang>`) or pass an installed language code from `--list-langs`.","Validate the input is an existing image file tesseract supports (PNG/JPEG/TIFF/BMP) before calling run().","Run `tesseract <input> stdout -l <langs>` manually to reproduce and see the full stderr."],"exampleFix":"// before\nlet text = ocr::run(&[pdf_path], \"por\", progress).await?;\n// after\nlet langs = ocr::status().await.languages;\nlet lang = if langs.contains(\"por\") { \"por\" } else { \"eng\" };\nlet text = ocr::run(&[img_path], lang, progress).await?;","handlingStrategy":"validation","validationCode":"let st = ocr::status().await;\nlet langs = st.languages;\nassert!(langs.contains(&\"por\".to_string()), \"idioma nao instalado; disponiveis: {langs:?}\");\nassert!(inputs.iter().all(|p| std::path::Path::new(p).is_file()), \"arquivo de entrada inexistente\");","typeGuard":null,"tryCatchPattern":"match ocr::run(&inputs, langs, progress).await {\n    Ok(r) => r,\n    Err(e) if e.to_string().contains(\"falhou em\") => {\n        // stderr is embedded after the input path; log and continue with next file\n        eprintln!(\"OCR skip: {e}\");\n        Vec::new()\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Validate inputs are existing image files (PNG/JPEG/TIFF/BMP) before calling run().","Query status().languages and intersect with requested languages, defaulting to \"eng\".","Convert PDFs/other formats to images before OCR; tesseract only reads raster images."],"tags":["ocr","tesseract","process-failed","language-data"],"backgroundTag":"command-failed","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}