{"record":{"id":"482fb1ed8b1da55d","repo":"tonhowtf/omniget","slug":"nenhuma-pagina-selecionada","errorCode":null,"errorMessage":"nenhuma pagina selecionada","messagePattern":"nenhuma pagina selecionada","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/pdf.rs","lineNumber":432,"sourceCode":"            } else {\n                out.extend((b..=a).rev());\n            }\n        } else {\n            let n: usize = part\n                .parse()\n                .map_err(|_| anyhow!(\"pagina invalida: {}\", part))?;\n            if n == 0 || n > total {\n                return Err(anyhow!(\n                    \"pagina fora do documento ({} paginas): {}\",\n                    total,\n                    n\n                ));\n            }\n            out.push(n);\n        }\n    }\n    if out.is_empty() {\n        return Err(anyhow!(\"nenhuma pagina selecionada\"));\n    }\n    Ok(out)\n}\n\nfn stem(path: &Path) -> String {\n    path.file_stem()\n        .map(|s| s.to_string_lossy().to_string())\n        .unwrap_or_else(|| \"documento\".into())\n}\n\nfn out_dir_for(input: &Path, output_dir: &str) -> PathBuf {\n    if output_dir.trim().is_empty() {\n        input\n            .parent()\n            .map(Path::to_path_buf)\n            .unwrap_or_else(|| PathBuf::from(\".\"))\n    } else {\n        PathBuf::from(output_dir.trim())","sourceCodeStart":414,"sourceCodeEnd":450,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/pdf.rs#L414-L450","documentation":"parse_ranges converts a user-supplied page-range string (e.g. \"1-3,5\") into a list of page indices. If the parsed result is empty — because the string is empty, malformed, or references no valid pages — it throws this Portuguese error (\"no page selected\"). All PDF tools (redaction_check, split, render, to_text, read_pages, read_raw_chars) funnel through it, so this error surfaces whenever a range selector resolves to zero pages.","triggerScenarios":"Calling any PDF operation with opts.ranges set to an empty string, whitespace, a token with no digits (e.g. \"abc\" or \"--\"), or out-of-bounds page numbers only (e.g. ranges \"50-60\" on a 10-page PDF, assuming the parser clamps invalid pages out).","commonSituations":"Users leaving the page-range field blank expecting \"all pages\"; pasting ranges with invalid separators; UI passing the wrong field (e.g. empty ranges while pages exist); locale issues where a translated range string reaches the parser.","solutions":["Ensure opts.ranges contains at least one valid page or range token (e.g. \"1\", \"1-3,5\").","Treat an empty ranges string as \"all pages\" by passing \"1-<total>\" from the caller.","Validate ranges against the document page count before invoking the tool.","Trim and normalize the string (remove stray commas/dashes) before calling."],"exampleFix":"// before\nto_text(&TextOptions { ranges: \"\".into(), .. })\n\n// after\nlet ranges = if opts.ranges.trim().is_empty() { format!(\"1-{}\", total) } else { opts.ranges.clone() };\nto_text(&TextOptions { ranges, .. })","handlingStrategy":"validation","validationCode":"let ranges = opts.ranges.trim();\nlet valid = !ranges.is_empty()\n    && ranges.split(',').any(|tok| {\n        tok.split('-').filter_map(|p| p.trim().parse::<usize>().ok()).count() > 0\n    });\nif !valid { return Err(\"provide at least one page, e.g. '1-3,5'\"); }","typeGuard":"fn has_pages(ranges: &str) -> bool {\n    ranges.split(',').any(|tok| {\n        tok.split('-').any(|p| p.trim().parse::<usize>().is_ok())\n    })\n}","tryCatchPattern":"match parse_ranges(&opts.ranges, total) {\n    Ok(pages) => use(pages),\n    Err(e) if e.to_string().contains(\"nenhuma pagina\") => {\n        let pages: Vec<usize> = (1..=total).collect(); // fall back to all pages\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Never pass an empty ranges string; default to \"1-<total>\" for \"all pages\".","Sanitize separators (spaces, stray commas) before calling.","Validate range endpoints against the document page count.","Show a live preview of resolved pages in the UI."],"tags":["pdf","page-ranges","validation","rust"],"backgroundTag":"empty-required-field","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"}