{"record":{"id":"00731282ed85f25d","repo":"tonhowtf/omniget","slug":"formato-nao-suportado","errorCode":null,"errorMessage":"formato nao suportado: {}","messagePattern":"formato nao suportado: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/pdf.rs","lineNumber":1327,"sourceCode":"}\n\n// ── LibreOffice (PDF ↔ Office) ─────────────────────────────────────────\n\npub async fn office_convert(\n    inputs: Vec<String>,\n    target: String,\n    output_dir: String,\n    progress: super::ProgressFn,\n) -> anyhow::Result<Vec<String>> {\n    let soffice = find_soffice()\n        .await\n        .ok_or_else(|| anyhow!(\"LibreOffice nao encontrado\"))?;\n    let target = target.trim().trim_start_matches('.').to_ascii_lowercase();\n    if !matches!(\n        target.as_str(),\n        \"docx\" | \"odt\" | \"pptx\" | \"xlsx\" | \"pdf\" | \"html\" | \"txt\" | \"epub\"\n    ) {\n        return Err(anyhow!(\"formato nao suportado: {}\", target));\n    }\n    let mut outputs = Vec::new();\n    let n = inputs.len() as u64;\n    for (i, input) in inputs.iter().enumerate() {\n        report(\n            &progress,\n            \"progress\",\n            i as u64,\n            Some(n),\n            Some(input.clone()),\n        );\n        let input_path = PathBuf::from(input.trim());\n        let dir = out_dir_for(&input_path, &output_dir);\n        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);","sourceCodeStart":1309,"sourceCodeEnd":1345,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/pdf.rs#L1309-L1345","documentation":"Validation error raised when the requested conversion target format is not in the allow-list of formats LibreOffice conversion supports (docx, odt, pptx, xlsx, pdf, html, txt, epub). The target string is trimmed, stripped of a leading dot, and lowercased before matching. Anything outside the list aborts before any file is processed.","triggerScenarios":"Calling the conversion API with target values like \"doc\", \"rtf\", \"csv\", \"DOCX \" (handled by trim), or \".odt\" variants outside the allowed set — e.g. `convert(inputs, \"docx2\", ...)`.","commonSituations":"Users passing legacy extensions like `.doc` or `.xls`, typos in the target format, or UI passing the full filename instead of just the extension.","solutions":["Use one of the supported targets: docx, odt, pptx, xlsx, pdf, html, txt, epub","Strip the leading dot and lowercase the extension before calling","Map unsupported formats (doc→docx, rtf→docx) before invoking","Extend the `matches!` allow-list if your LibreOffice build supports more formats"],"exampleFix":"// before\nconvert(&files, \"doc\", &dir, progress).await?;\n// after\nlet target = if ext == \"doc\" { \"docx\" } else { ext };\nconvert(&files, target, &dir, progress).await?;","handlingStrategy":"validation","validationCode":"const SUPPORTED: [&str; 8] = [\"docx\",\"odt\",\"pptx\",\"xlsx\",\"pdf\",\"html\",\"txt\",\"epub\"];\nfn is_supported(t: &str) -> bool {\n    SUPPORTED.contains(&t.trim().trim_start_matches('.').to_ascii_lowercase().as_str())\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate the target format against the allow-list in UI before calling","Normalize user input: trim, strip leading dot, lowercase","Map common legacy extensions (doc→docx, xls→xlsx) to supported targets","Keep a single shared constant for supported formats to avoid drift"],"tags":["validation","conversion","unsupported-format"],"backgroundTag":"unsupported-enum-value","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"}