tonhowtf/omniget · error

nada para tarjar: marque uma região ou digite um termo

Error message

nada para tarjar: marque uma região ou digite um termo

What it means

In pdf_redact's run(), after planning redaction rectangles from marked regions and search terms, plan_rects returned an empty set — nothing would be redacted — so the function fails with 'nada para tarjar: marque uma região ou digite um termo'.

Solutions

  1. Mark at least one region or enter a search term that exists in the document
  2. Verify opts.pages includes the pages where regions/terms are defined
  3. Check case-sensitivity/normalization of terms against extracted text
  4. Handle the empty plan in the UI with a pre-run validation message

Example fix

// before
let (rects, _) = plan_rects(&pages, &opts, &wanted);
run(&opts, &progress)?; // may fail with 'nada para tarjar'
// after
if opts.regions.is_empty() && opts.terms.iter().all(|t| t.trim().is_empty()) {
    bail!("mark a region or type a term first");
}
run(&opts, &progress)?;
Defensive patterns

Strategy: validation

Validate before calling

let pages = pdf::read_raw_chars(&opts.input, pw, "")?;
let wanted = pdf::parse_ranges(&opts.pages, pages.len())?;
let (rects, _) = plan_rects(&pages, &opts, &wanted);
if rects.is_empty() { bail!("nothing to redact: mark a region or enter a term"); }

Prevention

When it happens

Trigger: Calling run() with opts.regions empty AND opts.terms (search terms) either empty or not found anywhere in the selected pages, so rects.is_empty().

Common situations: User typed a term that does not appear in the document (case/format mismatch); marked regions on pages excluded by opts.pages; term matching failed due to encoding of extracted chars.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


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

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/pdf_redact.rs:851

pub fn run(opts: &Options, progress: &super::ProgressFn) -> anyhow::Result<RedactResult> {
    if opts.input.trim().is_empty() {
        return Err(anyhow!("escolha o PDF"));
    }
    let pw = if opts.password.is_empty() {
        None
    } else {
        Some(opts.password.as_str())
    };
    let dpi = if opts.dpi == 0 { 150 } else { opts.dpi };
    let quality = if opts.quality == 0 { 88 } else { opts.quality };

    report(progress, "progress", 0, 4, Some("lendo o PDF".into()));
    let pages = pdf::read_raw_chars(&opts.input, pw, "")?;
    let total_pages = pages.len();
    let wanted = pdf::parse_ranges(&opts.pages, total_pages)?;
    let (rects, terms_found) = plan_rects(&pages, opts, &wanted);
    if rects.is_empty() {
        return Err(anyhow!(
            "nada para tarjar: marque uma região ou digite um termo"
        ));
    }
    let areas_total: usize = rects.values().map(Vec::len).sum();

    let output = out_path(opts)?;
    let mut doc = load(&opts.input, &opts.password)?;
    let ids: BTreeMap<u32, lopdf::ObjectId> = doc.get_pages();
    let mut by_page: Vec<PageReport> = Vec::new();
    let mut chars_removed = 0usize;
    let mut fallback: Vec<usize> = Vec::new();
    let force_raster = opts.mode.trim() == "raster";

    report(progress, "progress", 1, 4, Some("apagando o texto".into()));
    for (no, rs) in &rects {
        let Some(page_id) = ids.get(&(*no as u32)).copied() else {
            continue;
        };

View on GitHub (pinned to 8600b91f42)