tonhowtf/omniget · error

escolha pelo menos um formato de saída

Error message

escolha pelo menos um formato de saída

What it means

In run(), each enabled output format (json, txt/md, etc.) writes a file and pushes its path to `files`. If `files` is empty, no output format option was requested, so the tool aborts with this error rather than downloading the thread and producing nothing.

Solutions

  1. Set at least one format flag to true, e.g. opts.json = true
  2. Validate the options before invoking the download to fail fast
  3. If multiple formats are desired, enable each one explicitly (files are written per enabled format)

Example fix

// before
let opts = ThreadOptions { dest: Some(dir), ..Default::default() }; // no format flag
// after
let opts = ThreadOptions { dest: Some(dir), json: true, ..Default::default() };
Defensive patterns

Strategy: validation

Validate before calling

if !(opts.json || opts.txt || opts.md) {
    return Err(anyhow!("pick at least one output format before downloading"));
}

Try / catch

match run(&progress, opts).await {
    Err(e) if e.to_string().contains("formato de saida") => {
        eprintln!("no output format selected; enable json/txt/md in options");
    }
    Err(e) => return Err(e),
    Ok(_) => {}
}

Prevention

When it happens

Trigger: Calling run() / baixa_uma_thread_publica_de_verdade with ThreadOptions where every format flag (opts.json, opts.txt, etc.) is false or omitted — validation happens after fetching but before the done report.

Common situations: Building options programmatically and forgetting to set any format flag; a config file defaulting all formats to false; UI passing only flags the user disabled.

Understand the failure class

Background: "Must pass :limit option" / "Missing required option" — required option errors explained — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/reddit/thread.rs:968

    let base = base.trim().to_string();
    let mut files = Vec::new();
    if opts.markdown {
        let path = out_path(&dest, &base, "md");
        std::fs::write(&path, render_markdown(&thread))?;
        files.push(path.to_string_lossy().to_string());
    }
    if opts.html {
        let path = out_path(&dest, &base, "html");
        std::fs::write(&path, render_html(&thread))?;
        files.push(path.to_string_lossy().to_string());
    }
    if opts.json {
        let path = out_path(&dest, &base, "json");
        std::fs::write(&path, serde_json::to_string_pretty(&thread)?)?;
        files.push(path.to_string_lossy().to_string());
    }
    if files.is_empty() {
        return Err(anyhow!("escolha pelo menos um formato de saída"));
    }
    report(
        &progress,
        ID,
        "done",
        total as u64,
        Some(total as u64),
        None,
    );
    Ok(ThreadResult {
        title: thread.post.title,
        subreddit: thread.post.subreddit,
        author: thread.post.author,
        permalink: thread.post.permalink,
        comments: total,
        missing,
        requests: fetcher.requests(),
        files,

View on GitHub (pinned to 8600b91f42)