tonhowtf/omniget · warning
intervalo invalido
Error message
intervalo invalido: {} What it means
parse_ranges could not parse the start bound of a range token like '5-' or 'a-b' as an unsigned integer. The offending token is included in the message. This is a user-input validation error inside the PDF page-selection parser.
Solutions
- Sanitize the range string: trim, accept only digits, '-' and ','
- Show the user the expected syntax (e.g. "1-3,5,8-") before accepting input
- Pre-parse ranges with a regex like ^\d*\s*-\s*\d*$ before calling the API
- Map this error to a user-facing 'invalid page range' message
Example fix
// before
let pages = parse_ranges(input, total)?;
// after
if !input.chars().all(|c| c.is_ascii_digit() || c == '-' || c == ',') {
anyhow::bail!("page range may contain only digits, '-' and ','");
}
let pages = parse_ranges(input, total)?; Defensive patterns
Strategy: validation
Validate before calling
fn valid_range_token(t: &str) -> bool {
let t = t.trim();
!t.is_empty() && t.chars().all(|c| c.is_ascii_digit() || c == '-') && t.matches('-').count() <= 1
} Type guard
fn is_page_spec(s: &str) -> bool { s.split(',').all(valid_range_token) } Try / catch
let pages = parse_ranges(input, total).map_err(|e|
anyhow!("invalid page selection '{}': {}", input, e))?; Prevention
- Validate the whole spec with a regex ^\d*(-\d*)?(,\d*(-\d*)?)*$ before calling
- Trim and normalize user input (strip spaces/NBSP)
- Show the accepted syntax in the UI placeholder
- Never build range strings by raw string interpolation of untrusted values
When it happens
Trigger: Calling any page-selection API (split, render, to_text, read_pages, redaction_check, read_raw_chars) with a range string whose left side of '-' is non-numeric, e.g. "abc-10", "2.5-7", "-1-5".
Common situations: Users typing ranges with spaces/locale digits, GUI passing unvalidated free-text page selectors, scripts interpolating variables that contain non-numeric junk.
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
- pagina invalida
- 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/831e46a0587e5f0f.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/pdf.rs:396
/// "1-3, 5, 8-" → páginas 1-based na ordem dada. Vazio ou "all" = todas.
pub fn parse_ranges(spec: &str, total: usize) -> anyhow::Result<Vec<usize>> {
let spec = spec.trim();
if spec.is_empty() || spec.eq_ignore_ascii_case("all") || spec == "*" {
return Ok((1..=total).collect());
}
let mut out = Vec::new();
for part in spec
.split([',', ' '])
.map(str::trim)
.filter(|p| !p.is_empty())
{
if let Some((a, b)) = part.split_once('-') {
let a: usize = if a.trim().is_empty() {
1
} else {
a.trim()
.parse()
.map_err(|_| anyhow!("intervalo invalido: {}", part))?
};
let b: usize = if b.trim().is_empty() {
total
} else {
b.trim()
.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 {View on GitHub (pinned to 8600b91f42)