tonhowtf/omniget · error

formato nao disponivel para

Error message

formato {} nao disponivel para {}

What it means

download() in gdocs.rs exports a Google Docs/Sheets/Slides file via the export URL. Before building the request it checks that the requested format (e.g. pdf, docx, xlsx, zip) is one of the formats valid for the parsed document kind. If not, it fails immediately with this message naming the format and the document kind.

Solutions

  1. Check info.kind and pass a format valid for that kind (Documents: pdf/docx/odt/txt/html; Sheets: xlsx/ods/csv/pdf; Slides: pdf/pptx/odp)
  2. Parse the URL first with parse() to inspect info.formats before choosing a format
  3. Fix the format string spelling/case used at the call site

Example fix

// before
download(url, "docx")?; // url is a Google Sheet
// after
let info = gdocs::parse(url).unwrap();
let fmt = if info.formats.contains(&"docx".to_string()) { "docx" } else { "pdf" };
download(url, fmt).await?;
Defensive patterns

Strategy: validation

Validate before calling

let info = gdocs::parse(url).context("URL invalida do Google Docs")?;
if !info.formats.iter().any(|f| f == format) {
    return Err(format!("formato {} nao disponivel para {:?}; use um de {:?}", format, info.kind, info.formats));
}

Type guard

fn format_supported(info: &DocInfo, format: &str) -> bool {
    info.formats.iter().any(|f| f == format)
}

Prevention

When it happens

Trigger: Calling download(url, format) where format is not in info.formats for the document kind parsed from the URL, e.g. requesting 'xlsx' for a Google Document or 'docx' for a Spreadsheet.

Common situations: Hardcoded export format strings that assume the link is a Document when the user pastes a Sheets or Slides link; typos in format names ('PDF' vs 'pdf'); UI dropdowns not filtered per document kind.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/gdocs.rs:65

        return urlencoding::decode(&s[..end]).ok().map(|c| c.to_string());
    }
    let i = v.find("filename=")?;
    let s = v[i + 9..].trim().trim_matches('"');
    let end = s.find(';').unwrap_or(s.len());
    Some(s[..end].trim_matches('"').to_string())
}

pub async fn download(
    url: &str,
    format: &str,
    dest_dir: &str,
    progress: super::ProgressFn,
) -> anyhow::Result<String> {
    let info = parse(url).ok_or_else(|| {
        anyhow!("cole um link de docs.google.com (Documentos, Apresentações ou Planilhas)")
    })?;
    if !info.formats.iter().any(|f| f == format) {
        return Err(anyhow!(
            "formato {} nao disponivel para {}",
            format,
            info.kind
        ));
    }
    let client = super::client()?;
    let export = export_url(&info, format);
    let resp = client.get(&export).send().await?;
    if resp.status().as_u16() == 401 || resp.status().as_u16() == 403 {
        return Err(anyhow!(
            "o arquivo nao e publico; abra no navegador e use Arquivo > Fazer download"
        ));
    }
    if !resp.status().is_success() {
        return Err(anyhow!("Google Docs: HTTP {}", resp.status()));
    }
    let name = resp
        .headers()

View on GitHub (pinned to 8600b91f42)