tonhowtf/omniget · error

formato nao suportado

Error message

formato nao suportado: {}

What it means

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.

Solutions

  1. Use one of the supported targets: docx, odt, pptx, xlsx, pdf, html, txt, epub
  2. Strip the leading dot and lowercase the extension before calling
  3. Map unsupported formats (doc→docx, rtf→docx) before invoking
  4. Extend the `matches!` allow-list if your LibreOffice build supports more formats

Example fix

// before
convert(&files, "doc", &dir, progress).await?;
// after
let target = if ext == "doc" { "docx" } else { ext };
convert(&files, target, &dir, progress).await?;
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED: [&str; 8] = ["docx","odt","pptx","xlsx","pdf","html","txt","epub"];
fn is_supported(t: &str) -> bool {
    SUPPORTED.contains(&t.trim().trim_start_matches('.').to_ascii_lowercase().as_str())
}

Prevention

When it happens

Trigger: 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", ...)`.

Common situations: Users passing legacy extensions like `.doc` or `.xls`, typos in the target format, or UI passing the full filename instead of just the extension.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/00731282ed85f25d. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/pdf.rs:1327

}

// ── LibreOffice (PDF ↔ Office) ─────────────────────────────────────────

pub async fn office_convert(
    inputs: Vec<String>,
    target: String,
    output_dir: String,
    progress: super::ProgressFn,
) -> anyhow::Result<Vec<String>> {
    let soffice = find_soffice()
        .await
        .ok_or_else(|| anyhow!("LibreOffice nao encontrado"))?;
    let target = target.trim().trim_start_matches('.').to_ascii_lowercase();
    if !matches!(
        target.as_str(),
        "docx" | "odt" | "pptx" | "xlsx" | "pdf" | "html" | "txt" | "epub"
    ) {
        return Err(anyhow!("formato nao suportado: {}", target));
    }
    let mut outputs = Vec::new();
    let n = inputs.len() as u64;
    for (i, input) in inputs.iter().enumerate() {
        report(
            &progress,
            "progress",
            i as u64,
            Some(n),
            Some(input.clone()),
        );
        let input_path = PathBuf::from(input.trim());
        let dir = out_dir_for(&input_path, &output_dir);
        std::fs::create_dir_all(&dir)?;
        let is_pdf = input_path
            .extension()
            .map(|e| e.eq_ignore_ascii_case("pdf"))
            .unwrap_or(false);

View on GitHub (pinned to 8600b91f42)