{"record":{"id":"d3cbe362b9298332","repo":"tonhowtf/omniget","slug":"libreoffice-nao-converteu","errorCode":null,"errorMessage":"LibreOffice nao converteu {}: {}","messagePattern":"LibreOffice nao converteu (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/pdf.rs","lineNumber":1359,"sourceCode":"        std::fs::create_dir_all(&dir)?;\n        let is_pdf = input_path\n            .extension()\n            .map(|e| e.eq_ignore_ascii_case(\"pdf\"))\n            .unwrap_or(false);\n        let mut cmd = crate::core::process::command(&soffice);\n        cmd.args([\"--headless\", \"--norestore\"]);\n        if is_pdf && target != \"pdf\" {\n            cmd.arg(\"--infilter=writer_pdf_import\");\n        }\n        cmd.arg(\"--convert-to\")\n            .arg(&target)\n            .arg(\"--outdir\")\n            .arg(&dir)\n            .arg(&input_path);\n        let o = cmd.output().await?;\n        let produced = dir.join(format!(\"{}.{}\", stem(&input_path), target));\n        if !o.status.success() || !produced.exists() {\n            return Err(anyhow!(\n                \"LibreOffice nao converteu {}: {}\",\n                input,\n                String::from_utf8_lossy(if o.stderr.is_empty() {\n                    &o.stdout\n                } else {\n                    &o.stderr\n                })\n                .trim()\n            ));\n        }\n        outputs.push(produced.to_string_lossy().to_string());\n    }\n    report(&progress, \"done\", n, Some(n), None);\n    Ok(outputs)\n}\n\n// ── Leitura posicionada (base do PDF → Markdown) ───────────────────────\n","sourceCodeStart":1341,"sourceCodeEnd":1377,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/pdf.rs#L1341-L1377","documentation":"Raised when the spawned `soffice --convert-to` command either exits non-zero or does not produce the expected output file. The message includes the input filename and LibreOffice's stderr (or stdout if stderr is empty), since LibreOffice sometimes reports failures only on stdout.","triggerScenarios":"soffice runs but fails to convert a given input (corrupt/encrypted source document, unsupported source variant), a concurrent soffice instance holds the user profile lock, or the output filename differs from the expected `<stem>.<target>`.","commonSituations":"Password-protected or DRM'd documents, running multiple conversions in parallel under the same user profile (`soffice` singleton lock), read-only output directory, filename stems containing characters LibreOffice rewrites.","solutions":["Run the exact soffice command manually to read the real error","Ensure no other soffice instance is running (kill lingering processes / use `-env:UserInstallation` per run)","Verify the input document opens correctly in LibreOffice or another viewer","Check write permission on the output directory","Retries sequentially instead of in parallel to avoid profile lock contention"],"exampleFix":"// before: parallel calls collide on the soffice profile lock\nlet results = join_all(files.iter().map(|f| convert_one(f, \"pdf\"))).await;\n// after: serialize conversions\nlet mut results = vec![];\nfor f in &files { results.push(convert_one(f, \"pdf\").await?); }","handlingStrategy":"try-catch","validationCode":"// Rust: pre-check input readability and no lingering soffice lock\nlet readable = tokio::fs::metadata(input).await.map(|m| !m.len().eq(&0)).unwrap_or(false);\nif !readable { return Err(anyhow!(\"entrada invalida: {}\", input)); }","typeGuard":null,"tryCatchPattern":"match convert_one(input, target).await {\n    Ok(out) => out,\n    Err(e) if e.to_string().contains(\"LibreOffice nao converteu\") => {\n        eprintln!(\"{e}\"); retry_with_fresh_profile(input, target).await\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Serialize soffice conversions or give each one its own UserInstallation profile","Reject password-protected/encrypted inputs up front","Check output directory write permissions before conversion","Log soffice stderr and stdout for every failure to aid diagnosis"],"tags":["external-process","libreoffice","conversion-failed"],"backgroundTag":"http-error-response","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}