tonhowtf/omniget · error
source do arXiv nao parece LaTeX
Error message
source do arXiv nao parece LaTeX
What it means
extract_source first gunzips the payload, then checks whether it is a tar. If it is not a tar, it treats the bytes as a single loose .tex file — but only if the decoded text contains a backslash. If there is no backslash, the content cannot plausibly be LaTeX, so this error is thrown.
Solutions
- Log the first bytes/content-type of the payload to identify what was actually downloaded.
- Re-download the source — a truncated fetch can leave non-LaTeX garbage.
- Check whether the paper uses PostScript (convert with ps2pdf or skip it).
- Verify you're hitting arxiv.org directly and not an HTML error page behind a proxy.
Example fix
// before
if !text.contains('\\') {
return Err(anyhow!("source do arXiv nao parece LaTeX"));
}
// after
if !text.contains('\\') {
anyhow::bail!("source do arXiv nao parece LaTeX (inicio: {:?})", &text.chars().take(120).collect::<String>());
} Defensive patterns
Strategy: validation
Validate before calling
// apos baixar e gunzipar:
let text = String::from_utf8_lossy(&raw);
if !is_tar(&raw) && !text.contains('\\') {
bail!("payload nao e tar nem LaTeX; content-type/inicio: {:?}", &raw[..raw.len().min(64)]);
} Try / catch
match extract_source(&bytes) {
Err(e) if e.to_string().contains("nao parece LaTeX") => {
eprintln!("fonte em formato nao suportado (PostScript/HTML?); pulando id");
}
other => other,
} Prevention
- Inspect the first bytes/content-type of the source payload before parsing.
- Verify downloads are complete (compare Content-Length) — truncation corrupts sniffing.
- Avoid proxies/mirrors that may inject HTML error pages.
When it happens
Trigger: The e-print payload is neither a tar nor LaTeX text: e.g. a PostScript file, a plain-text README, an HTML error page mis-served as the source, or binary garbage.
Common situations: Very old arXiv submissions stored as compressed PostScript; API/mirror returning an HTML block page for the source endpoint; corrupt or truncated download of the source bundle.
Understand the failure class
Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.
Related errors
- arXiv nao reconheceu o identificador
- o source deste arXiv e um PDF, nao tem LaTeX
- o tar do arXiv nao tem nenhum .tex
- nenhum .tex com \begin
- No valid cookies found in file (expected Netscape format)
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/779fcbf9b42edcb5.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/arxiv.rs:374
let mut out = Vec::new();
flate2::read::GzDecoder::new(b).read_to_end(&mut out)?;
Ok(out)
}
/// Aceita o tar.gz do `e-print`, um tar cru, um `.tex` gzipado ou o `.tex` solto.
pub fn extract_source(bytes: &[u8]) -> anyhow::Result<SourceBundle> {
if bytes.starts_with(b"%PDF") {
return Err(anyhow!("o source deste arXiv e um PDF, nao tem LaTeX"));
}
let raw = if is_gzip(bytes) {
gunzip(bytes)?
} else {
bytes.to_vec()
};
if !is_tar(&raw) {
let text = String::from_utf8_lossy(&raw).to_string();
if !text.contains('\\') {
return Err(anyhow!("source do arXiv nao parece LaTeX"));
}
return Ok(SourceBundle {
main: text,
files: vec!["main.tex".to_string()],
});
}
let mut texts: HashMap<String, String> = HashMap::new();
let mut names: Vec<String> = Vec::new();
let mut archive = tar::Archive::new(std::io::Cursor::new(&raw));
for entry in archive.entries()? {
let mut entry = entry?;
let path = entry.path()?.to_string_lossy().to_string();
let lower = path.to_lowercase();
if !(lower.ends_with(".tex") || lower.ends_with(".bbl") || lower.ends_with(".ltx")) {
continue;
}
let mut buf = Vec::new();View on GitHub (pinned to 8600b91f42)