tonhowtf/omniget · warning
pagina invalida
Error message
pagina invalida: {} What it means
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.
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
Example fix
// before
let n: usize = token.trim().parse().unwrap();
// after
let n: usize = token.trim().parse()
.map_err(|_| anyhow!("'{}' is not a page number", token))?; Defensive patterns
Strategy: validation
Validate before calling
fn is_page_number(t: &str) -> bool {
let t = t.trim();
!t.is_empty() && t.chars().all(|c| c.is_ascii_digit())
} Try / catch
let pages = parse_ranges(input, total)
.map_err(|e| anyhow!("could not read page number: {}", e))?; Prevention
- 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
When it happens
Trigger: 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).
Common situations: Locale-formatted numbers with separators pasted into the page field, OCR or AI-extracted page references containing stray text, spreadsheet exports with decimals.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- intervalo invalido
- pagina fora do documento
- Expected a JSON array of cookie objects.
- cor inválida
- nenhuma imagem
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/f150e7f89eb92db6.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/pdf.rs:420
.parse()
.map_err(|_| anyhow!("intervalo invalido: {}", part))?
};
if a == 0 || b == 0 || a > total || b > total {
return Err(anyhow!(
"pagina fora do documento ({} paginas): {}",
total,
part
));
}
if a <= b {
out.extend(a..=b);
} else {
out.extend((b..=a).rev());
}
} else {
let n: usize = part
.parse()
.map_err(|_| anyhow!("pagina invalida: {}", part))?;
if n == 0 || n > total {
return Err(anyhow!(
"pagina fora do documento ({} paginas): {}",
total,
n
));
}
out.push(n);
}
}
if out.is_empty() {
return Err(anyhow!("nenhuma pagina selecionada"));
}
Ok(out)
}
fn stem(path: &Path) -> String {
path.file_stem()View on GitHub (pinned to 8600b91f42)