{"record":{"id":"44fd27e9628b15ac","repo":"tonhowtf/omniget","slug":"nenhum-trecho-para-extrair","errorCode":null,"errorMessage":"nenhum trecho para extrair","messagePattern":"nenhum trecho para extrair","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/pdf.rs","lineNumber":902,"sourceCode":"                .map(|c| (format!(\"p{:03}-{:03}\", c[0], c[c.len() - 1]), c.to_vec()))\n                .collect()\n        }\n        \"ranges\" => opts\n            .ranges\n            .split(';')\n            .map(str::trim)\n            .filter(|s| !s.is_empty())\n            .map(|s| {\n                parse_ranges(s, total).map(|pages| (s.replace(' ', \"\").replace(',', \"_\"), pages))\n            })\n            .collect::<anyhow::Result<Vec<_>>>()?,\n        _ => vec![(\n            opts.ranges.replace(' ', \"\").replace(',', \"_\"),\n            parse_ranges(&opts.ranges, total)?,\n        )],\n    };\n    if groups.is_empty() {\n        return Err(anyhow!(\"nenhum trecho para extrair\"));\n    }\n    let dir = out_dir_for(input, &opts.output_dir);\n    std::fs::create_dir_all(&dir)?;\n    let base = stem(input);\n    let mut outputs = Vec::new();\n    let n = groups.len() as u64;\n    for (i, (label, pages)) in groups.iter().enumerate() {\n        report(progress, \"progress\", i as u64, Some(n), Some(label.clone()));\n        let dest = Document::new(api)?;\n        dest.import(&src, pages)?;\n        let path = unique(dir.join(format!(\"{} {}.pdf\", base, label)));\n        dest.save(&path)?;\n        outputs.push(path.to_string_lossy().to_string());\n    }\n    report(progress, \"done\", n, Some(n), None);\n    Ok(PdfOuts {\n        outputs,\n        pages: total,","sourceCodeStart":884,"sourceCodeEnd":920,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/pdf.rs#L884-L920","documentation":"After computing extraction groups (per split mode), if the groups vec is empty the tool throws \"nenhum trecho para extrair\" (\"no segment to extract\"). This guards the range-mode branch where parse_ranges produced page lists but the mode mapping yielded nothing to write.","triggerScenarios":"Calling split with mode \"ranges\" and an opts.ranges string that normalizes to an empty groups vec; effectively any ranges value that yields no extractable segment while not failing earlier in parse_ranges.","commonSituations":"Ranges string consisting only of separators (\",,\" or \" - \") that collapses to an empty name/list; mode string typo'd so it falls through to the default range branch with an unusable ranges value.","solutions":["Check opts.mode is one of the supported values (\"each\", \"every\", or the range mode) — typos fall through to range parsing.","Provide a non-empty, valid ranges string when not using each/every modes.","Validate groups/ranges in the caller before invoking split."],"exampleFix":"// before\nSplitOptions { mode: \"rangse\".into(), ranges: \"\".into(), .. }\n\n// after\nSplitOptions { mode: \"ranges\".into(), ranges: \"1-3\".into(), .. }","handlingStrategy":"validation","validationCode":"const MODES: [&str; 3] = [\"each\", \"every\", \"ranges\"];\nif !MODES.contains(&opts.mode.as_str()) {\n    return Err(format!(\"unknown split mode: {}\", opts.mode));\n}\nif opts.mode == \"ranges\" && !has_pages(&opts.ranges) {\n    return Err(\"ranges mode requires a valid page-range string\");\n}","typeGuard":"fn is_valid_mode(m: &str) -> bool { matches!(m, \"each\" | \"every\" | \"ranges\") }","tryCatchPattern":"match split(&opts, &progress) {\n    Ok(out) => use(out),\n    Err(e) if e.to_string().contains(\"nenhum trecho\") => {\n        eprintln!(\"mode '{}' with ranges '{}' produced nothing\", opts.mode, opts.ranges);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Validate the mode string against the enum of supported values (typos fall through to range parsing).","Require a non-empty ranges string for range-based splitting.","Unit-test each mode with edge-case range inputs."],"tags":["pdf","split","empty-result","rust"],"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-15T23:17:13.987Z"}