{"record":{"id":"f77e3b2ec9a5e82f","repo":"tonhowtf/omniget","slug":"nada-para-tarjar-marque-uma-regi-o-ou-digite-um-termo","errorCode":null,"errorMessage":"nada para tarjar: marque uma região ou digite um termo","messagePattern":"nada para tarjar: marque uma região ou digite um termo","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/pdf_redact.rs","lineNumber":851,"sourceCode":"pub fn run(opts: &Options, progress: &super::ProgressFn) -> anyhow::Result<RedactResult> {\n    if opts.input.trim().is_empty() {\n        return Err(anyhow!(\"escolha o PDF\"));\n    }\n    let pw = if opts.password.is_empty() {\n        None\n    } else {\n        Some(opts.password.as_str())\n    };\n    let dpi = if opts.dpi == 0 { 150 } else { opts.dpi };\n    let quality = if opts.quality == 0 { 88 } else { opts.quality };\n\n    report(progress, \"progress\", 0, 4, Some(\"lendo o PDF\".into()));\n    let pages = pdf::read_raw_chars(&opts.input, pw, \"\")?;\n    let total_pages = pages.len();\n    let wanted = pdf::parse_ranges(&opts.pages, total_pages)?;\n    let (rects, terms_found) = plan_rects(&pages, opts, &wanted);\n    if rects.is_empty() {\n        return Err(anyhow!(\n            \"nada para tarjar: marque uma região ou digite um termo\"\n        ));\n    }\n    let areas_total: usize = rects.values().map(Vec::len).sum();\n\n    let output = out_path(opts)?;\n    let mut doc = load(&opts.input, &opts.password)?;\n    let ids: BTreeMap<u32, lopdf::ObjectId> = doc.get_pages();\n    let mut by_page: Vec<PageReport> = Vec::new();\n    let mut chars_removed = 0usize;\n    let mut fallback: Vec<usize> = Vec::new();\n    let force_raster = opts.mode.trim() == \"raster\";\n\n    report(progress, \"progress\", 1, 4, Some(\"apagando o texto\".into()));\n    for (no, rs) in &rects {\n        let Some(page_id) = ids.get(&(*no as u32)).copied() else {\n            continue;\n        };","sourceCodeStart":833,"sourceCodeEnd":869,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/pdf_redact.rs#L833-L869","documentation":"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'.","triggerScenarios":"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().","commonSituations":"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.","solutions":["Mark at least one region or enter a search term that exists in the document","Verify opts.pages includes the pages where regions/terms are defined","Check case-sensitivity/normalization of terms against extracted text","Handle the empty plan in the UI with a pre-run validation message"],"exampleFix":"// before\nlet (rects, _) = plan_rects(&pages, &opts, &wanted);\nrun(&opts, &progress)?; // may fail with 'nada para tarjar'\n// after\nif opts.regions.is_empty() && opts.terms.iter().all(|t| t.trim().is_empty()) {\n    bail!(\"mark a region or type a term first\");\n}\nrun(&opts, &progress)?;","handlingStrategy":"validation","validationCode":"let pages = pdf::read_raw_chars(&opts.input, pw, \"\")?;\nlet wanted = pdf::parse_ranges(&opts.pages, pages.len())?;\nlet (rects, _) = plan_rects(&pages, &opts, &wanted);\nif rects.is_empty() { bail!(\"nothing to redact: mark a region or enter a term\"); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pre-check search terms against extracted text before running","Ensure marked regions belong to selected pages","Normalize case when matching terms"],"tags":["pdf","redaction","validation","empty-result"],"backgroundTag":"empty-result-set","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}