{"record":{"id":"f150e7f89eb92db6","repo":"tonhowtf/omniget","slug":"pagina-invalida","errorCode":null,"errorMessage":"pagina invalida: {}","messagePattern":"pagina invalida: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src-tauri/omniget-core/src/core/tools/pdf.rs","lineNumber":420,"sourceCode":"                    .parse()\n                    .map_err(|_| anyhow!(\"intervalo invalido: {}\", part))?\n            };\n            if a == 0 || b == 0 || a > total || b > total {\n                return Err(anyhow!(\n                    \"pagina fora do documento ({} paginas): {}\",\n                    total,\n                    part\n                ));\n            }\n            if a <= b {\n                out.extend(a..=b);\n            } 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()","sourceCodeStart":402,"sourceCodeEnd":438,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/pdf.rs#L402-L438","documentation":"Parse failure in parse_ranges: a page-range token is not a valid integer (or falls outside the document's page count in the sibling check), so the requested selection cannot be mapped to real pages and the operation aborts.","triggerScenarios":"Calling any page-selection API with a token like \"abc\", \"1.5\", \"1e2\", or a token containing thousands separators such as \"1,000\" (note: comma is the token separator here, so \"1,000\" becomes two tokens \"1\" and \"000\" — the latter parses fine, but \"1 000\" with a space does not).","commonSituations":"Locale-formatted numbers with separators pasted into the page field, OCR or AI-extracted page references containing stray text, spreadsheet exports with decimals.","solutions":["Strip whitespace and validate each token is pure ASCII digits before calling","Normalize locale separators (remove spaces, NBSP, apostrophes) from user input","Use Rust's str::parse::<usize>() in a pre-check and reject early with a clear message","Constrain UI inputs to number fields rather than free text"],"exampleFix":"// before\nlet n: usize = token.trim().parse().unwrap();\n// after\nlet n: usize = token.trim().parse()\n    .map_err(|_| anyhow!(\"'{}' is not a page number\", token))?;","handlingStrategy":"validation","validationCode":"fn is_page_number(t: &str) -> bool {\n    let t = t.trim();\n    !t.is_empty() && t.chars().all(|c| c.is_ascii_digit())\n}","typeGuard":null,"tryCatchPattern":"let pages = parse_ranges(input, total)\n    .map_err(|e| anyhow!(\"could not read page number: {}\", e))?;","preventionTips":["Use numeric input controls instead of free-text for single pages","Strip thousands separators and whitespace before parsing","Reject tokens containing letters or decimal points up front","Add parser tests covering 'abc', '1.5', and empty tokens"],"tags":["pdf","parsing","validation","user-input"],"backgroundTag":"invalid-argument-format","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"}