tonhowtf/omniget · error · anyhow

o modelo baixado não confere: esperava sha256

Error message

o modelo baixado não confere: esperava sha256 {expected}, veio {got}

What it means

After downloading to a temp file, `ensure_model` computes the file's sha256 and compares it with the CATALOG's expected hash; a mismatch deletes the temp file and returns 'o modelo baixado não confere: esperava sha256 {expected}, veio {got}'. This integrity gate prevents corrupted or tampered model weights from being installed.

Solutions

  1. Simply retry the download (the bad temp file is already removed) — transient truncation is the most common cause.
  2. Download the URL manually and run `sha256sum` to see if the upstream file changed; if it did, update the catalog's sha256 (and bytes) entry.
  3. Check whether a proxy/antivirus is intercepting the download and bypass it; ensure enough disk space so the file isn't truncated.

Example fix

// before
let path = onnx::ensure_model(id, &progress).await?;
// after
let path = match onnx::ensure_model(id, &progress).await {
    Ok(p) => p,
    Err(e) if e.to_string().contains("sha256") => {
        // checksum mismatch: retry once; if it persists, upstream changed
        onnx::ensure_model(id, &progress).await?
    }
    Err(e) => return Err(e),
};
Defensive patterns

Strategy: retry

Validate before calling

// nothing to check beforehand; instead ensure reliable transfer conditions
let free = fs2::available_space(models_dir)
    .unwrap_or(0);
assert!(free > spec_bytes * 2, "espaco insuficiente para baixar e verificar o modelo");

Try / catch

match onnx::ensure_model(id, &progress).await {
    Err(e) if e.to_string().contains("sha256") => {
        tokio::time::sleep(Duration::from_secs(5)).await;
        onnx::ensure_model(id, &progress).await // one clean retry; temp file was already removed
    }
    other => other,
}

Prevention

When it happens

Trigger: Calling `ensure_model` when the downloaded bytes do not match the catalog sha256: truncated/interrupted download, corrupted CDN/mirror response, an HTML error page saved instead of the model, or the upstream file was updated while the catalog still pins the old hash.

Common situations: Flaky network with silent truncation; a proxy/captive portal injecting a block page; upstream release replaced the onnx file without the app catalog being updated; disk corruption.

Understand the failure class

Background: Checksum mismatch errors: "checksum verification failed", "digest mismatch", "expected vs actual checksum" — what they mean and how to fix them — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/onnx.rs:227

    let expected = spec.sha256.to_string();
    let tmp2 = tmp.clone();
    let dest2 = dest.clone();
    let p = progress.clone();
    let pid2 = pid.clone();
    tokio::task::spawn_blocking(move || -> anyhow::Result<()> {
        super::report(
            &p,
            &pid2,
            "verify",
            0,
            None,
            Some("conferindo sha256".into()),
        );
        let got = sha256_of(&tmp2)?;
        if got != expected {
            let _ = std::fs::remove_file(&tmp2);
            return Err(anyhow!(
                "o modelo baixado não confere: esperava sha256 {expected}, veio {got}"
            ));
        }
        if dest2.exists() {
            let _ = std::fs::remove_file(&dest2);
        }
        std::fs::rename(&tmp2, &dest2)
            .with_context(|| format!("movendo para {}", dest2.display()))?;
        Ok(())
    })
    .await
    .map_err(|e| anyhow!("tarefa de verificação falhou: {e}"))??;

    super::report(progress, &pid, "done", 1, Some(1), None);
    Ok(dest)
}

/// Apaga um modelo baixado.

View on GitHub (pinned to 8600b91f42)