{"record":{"id":"4b16494d6fc9e6ef","repo":"AutoDarkMode/Windows-Auto-Night-Mode","slug":"failed-to-download-http","errorCode":null,"errorMessage":"Failed to download: HTTP {}","messagePattern":"Failed to download: HTTP (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"adm-downloader-rs/src/main.rs","lineNumber":125,"sourceCode":"    // prefer the installer's code if present.\r\n    if let Some(code) = installer_code {\r\n        exit(code);\r\n    }\r\n\r\n    // otherwise if we mapped a specific error code, return that.\r\n    if let Some(code) = program_error_code {\r\n        exit(code);\r\n    }\r\n\r\n    println!(\"done.\");\r\n    Ok(())\r\n}\r\n\r\nfn download_file(url: &str, dest: &PathBuf) -> anyhow::Result<()> {\r\n    let client = Client::new();\r\n    let resp = client.get(url).send()?;\r\n    if !resp.status().is_success() {\r\n        anyhow::bail!(\"Failed to download: HTTP {}\", resp.status());\r\n    }\r\n\r\n    let mut file = File::create(dest)?;\r\n    let bytes = resp.bytes()?;\r\n    let mut content = bytes.as_ref();\r\n    copy(&mut content, &mut file)?;\r\n    Ok(())\r\n}\r\n\r\n/// print package name and version pairs from the embedded Cargo.lock.\r\nfn print_updater_licenses() {\r\n    // embed the prepared HTML at compile time and open it in the default browser.\r\n    const HTML: &str = include_str!(\"../license.html\");\r\n\r\n    // write to a deterministic temp filename so it can be opened.\r\n    let mut out = std::env::temp_dir();\r\n    out.push(\"adm-updater-licenses.html\");\r\n    if let Err(e) = std::fs::write(&out, HTML) {\r","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/AutoDarkMode/Windows-Auto-Night-Mode/blob/c15b28e92138a1baff6165bbca80842f06cb819f/adm-downloader-rs/src/main.rs#L107-L143","documentation":"Returned (via anyhow::bail) by download_file in the Rust installer downloader when the HTTP GET to the installer URL returns a non-success status. The URL is built from a hardcoded GitHub release base plus an architecture-detected filename (ARM64 or x86). The error is mapped to exit code ERR_DOWNLOAD (13370) by run_install_flow.","triggerScenarios":"download_file(url, dest) issues client.get(url).send(); resp.status().is_success() is false. The URL points at a GitHub release asset (e.g. https://github.com/AutoDarkMode/.../AutoDarkMode_11.0.0.54_x86.exe).","commonSituations":"The release/asset was removed or renamed (404); GitHub rate-limited the unauthenticated request (403); the hardcoded version 11.0.0.54 no longer exists; network proxy/firewall blocked the request; transient server error (5xx).","solutions":["Verify the release URL is valid and the asset exists at the hardcoded version (open it in a browser).","Retry — GitHub 403/5xx and transient network errors are often intermittent.","Check network connectivity, proxy, and firewall rules blocking github.com.","Update the hardcoded base URL / version in main.rs if the release moved.","Run with network tracing (e.g. set RUST_LOG/HTTPS_PROXY) to capture the exact status code."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Verify the asset URL is reachable before downloading\nfn check_url_reachable(url: &str) -> anyhow::Result<()> {\n    let resp = Client::new().head(url).send()?;\n    if !resp.status().is_success() {\n        anyhow::bail!(\"asset URL not reachable: HTTP {}\", resp.status());\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":"// run_install_flow already maps this to ERR_DOWNLOAD. Add limited retries\n// for transient 5xx/403 before giving up:\nlet mut last = None;\nfor _ in 0..3 {\n    match download_file(url, dest) { Ok(()) => return Ok(()), Err(e) => { last = Some(e); std::thread::sleep(Duration::from_secs(2)); } }\n}\neprintln!(\"download failed: {}\", last.unwrap());\nreturn Err(ERR_DOWNLOAD);","preventionTips":["Pin the downloader to a release version whose assets are confirmed published.","Retry transient HTTP failures (5xx, 403 rate-limit) a few times before bailing.","Ensure network/proxy/firewall allows egress to github.com.","Log the exact HTTP status so the failure is diagnosable without a debugger."],"tags":["network","http","download","github-release","rust"],"backgroundTag":null,"analyzedSha":"c15b28e92138a1baff6165bbca80842f06cb819f","analyzedAt":"2026-08-13T21:04:56.049Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}