{"record":{"id":"5cfd3202a71d512a","repo":"netchx/netch","slug":"the-downloaded-file-has-the-wrong-hash","errorCode":null,"errorMessage":"The downloaded file has the wrong hash","messagePattern":"The downloaded file has the wrong hash","errorType":"exception","errorClass":"MessageException","httpStatus":null,"severity":"error","filePath":"Netch/Forms/MainForm.cs","lineNumber":473,"sourceCode":"                else\n                    File.Delete(updateFileFullName);\n            }\n\n            if (!downloaded)\n            {\n                try\n                {\n                    await WebUtil.DownloadFileAsync(updateFileUrl, updateFileFullName, progress);\n                }\n                catch (Exception e1)\n                {\n                    Log.Warning(e1, \"Download Update File Failed\");\n                    throw new MessageException($\"Download Update File Failed: {e1.Message}\");\n                }\n\n                var fileHash = await Utils.Utils.Sha256CheckSumAsync(updateFileFullName);\n                if (fileHash != sha256)\n                    throw new MessageException(i18N.Translate(\"The downloaded file has the wrong hash\"));\n            }\n\n            await StopAsync();\n            await Configuration.SaveAsync();\n\n            // Update\n            await Task.Run(updater.ApplyUpdate);\n\n            // release mutex, exit\n            Program.SingleInstance.Dispose();\n            Process.Start(Global.NetchExecutable);\n            Environment.Exit(0);\n        }\n        catch (MessageException exception)\n        {\n            NotifyTip(exception.Message, info: false);\n        }\n        catch (Exception exception)","sourceCodeStart":455,"sourceCodeEnd":491,"githubUrl":"https://github.com/netchx/netch/blob/9d99eb1c5a2acbf2a34f2600f94242601019a300/Netch/Forms/MainForm.cs#L455-L491","documentation":"Thrown by MainForm's update routine when the SHA-256 of the freshly downloaded update file does not equal the expected sha256 from UpdateChecker.GetLatestUpdateFileNameAndHash. The file is present but its content does not match the published hash, so the updater refuses to apply it.","triggerScenarios":"Partial/corrupted download truncated by a dropped connection; a transparent proxy/MITM altered the bytes; the published hash in the release metadata is stale or wrong; the GitHub asset was republished under the same name with different content; disk write corruption.","commonSituations":"Connection dropped mid-download leaving a truncated file; CDN/cache served a stale or wrong artifact; user is behind a filtering proxy that rewrote the binary.","solutions":["Delete data\\<updateFileName> and retry the download to get a clean copy.","Verify network path integrity (disable interfering proxy/VPN for the download).","Compare the published sha256 in the release notes against what Utils.Utils.Sha256CheckSumAsync computes locally.","If the published hash itself is wrong, wait for a corrected release or report it.","Download the asset manually in a browser, hash it, and only place it in data\\ if it matches."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// If a partial file exists, recompute and only trust it when it matches.\nif (File.Exists(updateFileFullName))\n{\n    if (await Utils.Utils.Sha256CheckSumAsync(updateFileFullName) != sha256)\n        File.Delete(updateFileFullName); // discard corrupt/partial file\n}","typeGuard":null,"tryCatchPattern":"string fileHash;\ndo\n{\n    try { await WebUtil.DownloadFileAsync(updateFileUrl, updateFileFullName, progress); }\n    catch (Exception e1) { throw new MessageException($\"Download Update File Failed: {e1.Message}\"); }\n    fileHash = await Utils.Utils.Sha256CheckSumAsync(updateFileFullName);\n    if (fileHash != sha256) File.Delete(updateFileFullName); // throw away the bad copy and retry\n} while (fileHash != shaHash);","preventionTips":["Delete the mismatched file and re-download — a truncated copy is the usual cause.","Disable interfering proxies/VPN for the download to avoid byte rewriting.","Cross-check the published sha256 against the GitHub release notes manually.","If the published hash is wrong, wait for a corrected release rather than forcing an apply."],"tags":["update","download","integrity","hash"],"backgroundTag":null,"analyzedSha":"9d99eb1c5a2acbf2a34f2600f94242601019a300","analyzedAt":"2026-08-13T14:12:19.105Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}