AutoDarkMode/Windows-Auto-Night-Mode · error · anyhow::Error

Failed to fetch sha256: HTTP {}

Error message

Failed to fetch sha256: HTTP {}

What it means

Returned by fetch_expected_sha256 when the HTTP GET for the sidecar checksum file (url + ".sha256") returns a non-success status. The downloader assumes a SHA256 file exists alongside every release asset. The error is part of the verify step and contributes to exit code ERR_VERIFY (13371).

Source

Thrown at adm-downloader-rs/src/main.rs:162

        eprintln!("failed to write embedded license HTML to {:?}: {}", out, e);
        return;
    }

    // use the Windows shell to open the file with the default application (browser).
    // `start` requires a title argument; pass an empty title string.
    let path_str = out.to_string_lossy().to_string();
    if let Err(e) = Command::new("cmd").args(["/C", "start", "", &path_str]).status() {
        eprintln!("failed to open license HTML in browser: {}", e);
    }
}

fn fetch_expected_sha256(url: &str) -> anyhow::Result<Vec<u8>> {
    // construct URL for the .sha256 file (assume same name + .sha256)
    let sha_url = format!("{}.sha256", url);
    let client = Client::new();
    let resp = client.get(&sha_url).send()?;
    if !resp.status().is_success() {
        anyhow::bail!("Failed to fetch sha256: HTTP {}", resp.status());
    }
    let text = resp.text()?;
    // file should contain the hex hash (optionally followed by filename)
    let hash_str = text
        .split_whitespace()
        .next()
        .ok_or_else(|| anyhow::anyhow!("Empty sha256 file"))?;
    let bytes = Vec::from_hex(hash_str)?;
    Ok(bytes)
}

fn compute_file_sha256(path: &PathBuf) -> anyhow::Result<Vec<u8>> {
    let mut f = File::open(path)?;
    let mut hasher = Sha256::new();
    let mut buf = [0u8; 8192];
    loop {
        let n = f.read(&mut buf)?;
        if n == 0 {

View on GitHub (pinned to c15b28e921)

Solutions

  1. Confirm the .sha256 file exists at the expected URL (open url + ".sha256" in a browser).
  2. Retry to rule out transient GitHub 403/5xx.
  3. If the project stopped shipping sidecar checksums, update verify_sha256 to fetch the hash from the release API/manifest instead.
  4. Check proxy/firewall and network connectivity to github.com.
  5. Pin the downloader to a release version that is known to publish the .sha256 file.
Defensive patterns

Strategy: retry

Validate before calling

// Confirm the .sha256 sidecar exists before the main flow
fn sha_sidecar_exists(url: &str) -> bool {
    Client::new().get(&format!("{}.sha256", url)).send().map(|r| r.status().is_success()).unwrap_or(false)
}

Try / catch

// verify_sha256 -> fetch_expected_sha256 already returns Result mapped to ERR_VERIFY.
// Retry transient failures and distinguish 404 (permanent) from 5xx (transient):
let resp = client.get(&sha_url).send()?;
if resp.status() == reqwest::StatusCode::NOT_FOUND {
    anyhow::bail!("sha256 sidecar not published for this asset (404)");
}
if !resp.status().is_success() {
    anyhow::bail!("Failed to fetch sha256: HTTP {}", resp.status());
}

Prevention

When it happens

Trigger: fetch_expected_sha256(url) builds sha_url = format!("{}.sha256", url) and GETs it. resp.status().is_success() is false — the .sha256 sidecar file is missing or the server errored.

Common situations: The release pipeline did not publish a .sha256 sidecar for the asset (404); version mismatch where the asset exists but the checksum file was not uploaded; GitHub rate-limiting (403); proxy/firewall block.

Related errors


AI-assisted analysis of AutoDarkMode/Windows-Auto-Night-Mode@c15b28e921 (2026-08-13). Data as JSON: /api/errors/94e0dd272672293e. Report an issue: GitHub.