tonhowtf/omniget · error

cole um link de docs.google.com (Documentos, Apresentações…

Error message

cole um link de docs.google.com (Documentos, Apresentações ou Planilhas)

What it means

download() parses the user-supplied URL with parse(url); if it does not match a Google Docs/Slides/Sheets document URL, parse returns None and this error is raised. It is an input validation error telling the user to paste a valid docs.google.com link.

Solutions

  1. Open the document in the browser and copy the URL while editing it — it must start with https://docs.google.com and contain the document ID
  2. Verify the URL matches one of the supported kinds (Documentos/Apresentações/Planilhas) before calling
  3. For Drive-stored files, use the appropriate Drive export/download API instead of this function

Example fix

// before
let url = "https://drive.google.com/file/d/ABC123"; // wrong host
// after
let url = "https://docs.google.com/document/d/ABC123/edit";
Defensive patterns

Strategy: validation

Validate before calling

// rust
fn looks_like_gdocs(url: &str) -> bool {
    let u = url.trim();
    u.starts_with("https://docs.google.com/")
        && (u.contains("/document/") || u.contains("/presentation/") || u.contains("/spreadsheets/"))
}

Try / catch

match gdocs::download(url, format, dest, progress).await {
    Ok(path) => path,
    Err(e) if e.to_string().contains("docs.google.com") => {
        anyhow::bail!("URL invalida: copie o link de edicao do documento no docs.google.com")
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling download() with a URL that parse() cannot recognize: non-Google URL, a drive.google.com file link, a docs URL missing the document ID, malformed URL, or empty string.

Common situations: User pastes a Google Drive file link instead of an open docs.google.com document link; URL copied from the file list without the document ID; shortened or redirected URL; typo in the domain.

Understand the failure class

Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.

Related errors


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

Appendix: source

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

    if let Some(i) = v.find("filename*=UTF-8''") {
        let s = &v[i + 17..];
        let end = s.find(';').unwrap_or(s.len());
        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()));

View on GitHub (pinned to 8600b91f42)