tonhowtf/omniget · error

nao reconheci um id de arXiv em

Error message

nao reconheci um id de arXiv em: {}

What it means

fetch() starts by running parse_id on opts.input; if the input string does not match any recognized arXiv identifier format (modern 2101.12345, old quant-ph/9901001, full abs URL, etc.), it fails with this message echoing the trimmed input. It is a client-side pre-flight validation before any network request.

Solutions

  1. Check the echoed input in the message and correct it to a valid arXiv id (e.g. 1706.03762 or https://arxiv.org/abs/1706.03762).
  2. Run parse_id on the input yourself first to get a precise reason and show the accepted formats to the user.
  3. Strip surrounding decorations like 'arXiv:' prefix, version suffixes, or trailing punctuation before calling.
  4. If the input is a DOI, resolve it to an arXiv id via arXiv's metadata or reject it explicitly.

Example fix

// before
let r = parse_id(&opts.input)
    .ok_or_else(|| anyhow!("nao reconheci um id de arXiv em: {}", opts.input.trim()))?;
// after
let cleaned = opts.input.trim().trim_start_matches("arXiv:").trim();
let r = parse_id(cleaned)
    .ok_or_else(|| anyhow!("nao reconheci um id de arXiv em: '{}' (esperado ex.: 1706.03762 ou quant-ph/9901001)", cleaned))?;
Defensive patterns

Strategy: validation

Validate before calling

// antes de chamar fetch:
fn e_id_arxiv(s: &str) -> bool {
    let s = s.trim().trim_start_matches("arXiv:").trim();
    regex::Regex::new(r"^(\d{4}\.\d{4,5}(v\d+)?|[a-z-]+/\d{7}(v\d+)?)$").unwrap().is_match(s)
}

Try / catch

match fetch(opts).await {
    Err(e) if e.to_string().contains("nao reconheci um id") => {
        eprintln!("entrada invalida: use 1706.03762 ou https://arxiv.org/abs/1706.03762");
    }
    other => other,
}

Prevention

When it happens

Trigger: Calling fetch with a DOI, title, bibkey, malformed URL, extra whitespace/characters, or a paper id with unsupported prefix (e.g. SSRN or bioRxiv ids).

Common situations: User pastes a DOI (10.xxxx/...) or a Google Scholar link instead of an arXiv id; copies a PDF download URL rather than the abs page; typos like 'arXiv: 1706.03762' with a space or missing digits.

Understand the failure class

Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/ae681abe5f4d41ff. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/arxiv.rs:1132

    pub body_source: String,
    pub path: Option<String>,
    pub chars: u64,
    pub math_blocks: u64,
    pub source_files: Vec<String>,
    /// Por que caiu para uma fonte pior, quando caiu.
    pub fallback_reason: Option<String>,
}

fn count_math(md: &str) -> u64 {
    split_math(md)
        .iter()
        .filter(|s| matches!(s, Span::Math(_)))
        .count() as u64
}

pub async fn fetch(opts: Options, p: ProgressFn) -> anyhow::Result<ArxivDoc> {
    let r = parse_id(&opts.input)
        .ok_or_else(|| anyhow!("nao reconheci um id de arXiv em: {}", opts.input.trim()))?;
    report(&p, ID, "started", 0, Some(3), Some(r.full()));

    let client = super::client()?;
    let url = format!("{}{}", API, r.full());
    let xml = client
        .get(&url)
        .send()
        .await?
        .error_for_status()?
        .text()
        .await?;
    let mut meta = parse_atom(&xml)?;
    if meta.version.is_none() {
        meta.version = r.version;
    }
    report(&p, ID, "progress", 1, Some(3), Some(meta.title.clone()));

    let prefer = if opts.prefer.is_empty() {

View on GitHub (pinned to 8600b91f42)