{"record":{"id":"a11ff6ea93c93bf0","repo":"HMCL-dev/HMCL","slug":"unsupported-checksum-type","errorCode":null,"errorMessage":"Unsupported checksum type: ","messagePattern":"Unsupported checksum type: ","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"HMCL/src/main/java/org/jackhuang/hmcl/ui/main/JavaDownloadDialog.java","lineNumber":385,"sourceCode":"\n            DiscoJavaDistribution distribution = distributionBox.getSelectionModel().getSelectedItem();\n            DiscoJavaRemoteVersion version = remoteVersionBox.getSelectionModel().getSelectedItem();\n            JavaPackageType packageType = packageTypeBox.getSelectionModel().getSelectedItem();\n\n            if (version == null)\n                return;\n\n            Controllers.taskDialog(new GetTask(downloadProvider.injectURLWithCandidates(version.getLinks().pkgInfoUri()))\n                    .setExecutor(Schedulers.io())\n                    .thenComposeAsync(json -> {\n                        DiscoResult<DiscoRemoteFileInfo> result = JsonUtils.fromNonNullJson(json, DiscoResult.typeOf(DiscoRemoteFileInfo.class));\n                        if (result.getResult().size() != 1)\n                            throw new IOException(\"Illegal result: \" + json);\n\n                        DiscoRemoteFileInfo fileInfo = result.getResult().get(0);\n                        if (StringUtils.isNotBlank(fileInfo.checksumType())\n                                && !fileInfo.checksumType().equals(\"sha1\") && !fileInfo.checksumType().equals(\"sha256\") && !fileInfo.checksumType().equals(\"md5\"))\n                            throw new IOException(\"Unsupported checksum type: \" + fileInfo.checksumType());\n                        if (StringUtils.isBlank(fileInfo.directDownloadUri()))\n                            throw new IOException(\"Missing download URI: \" + json);\n\n                        Path targetFile = Files.createTempFile(\"hmcl-java-\", \".\" + version.getArchiveType());\n                        targetFile.toFile().deleteOnExit();\n\n                        Task<FileDownloadTask.IntegrityCheck> getIntegrityCheck;\n                        if (StringUtils.isNotBlank(fileInfo.checksum()))\n                            getIntegrityCheck = Task.completed(new FileDownloadTask.IntegrityCheck(fileInfo.checksumType(), fileInfo.checksum()));\n                        else if (StringUtils.isNotBlank(fileInfo.checksumUri()))\n                            getIntegrityCheck = new GetTask(downloadProvider.injectURLWithCandidates(fileInfo.checksumUri()))\n                                    .thenApplyAsync(checksum -> {\n                                        checksum = checksum.trim();\n\n                                        int idx = checksum.indexOf(' ');\n                                        if (idx > 0)\n                                            checksum = checksum.substring(0, idx);\n","sourceCodeStart":367,"sourceCodeEnd":403,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCL/src/main/java/org/jackhuang/hmcl/ui/main/JavaDownloadDialog.java#L367-L403","documentation":"In the same Disco download flow, after resolving a package the code validates its reported checksum type. Only sha1, sha256, and md5 are supported; a blank checksum type is tolerated. If Disco reports any other checksum algorithm, the dialog throws IOException(\"Unsupported checksum type: ...\") because the downloaded archive could not be verified.","triggerScenarios":"Downloading a Java runtime whose DiscoRemoteFileInfo.checksumType() is a non-blank value other than \"sha1\", \"sha256\", or \"md5\" (e.g. a newer algorithm such as sha512).","commonSituations":"Upstream foojay API starts advertising a new checksum algorithm; a distribution entry uses an exotic hashing scheme; older HMCL releases lacking support for newer checksum types.","solutions":["Update HMCL to the latest version, which may support the new checksum type","Check the message for the reported type and verify upstream changed its checksum field","Download the JDK manually and register it through Java management instead of the in-app downloader","If developing, add the missing algorithm to the allow-list and compute it with MessageDigest"],"exampleFix":"// before\n&& !fileInfo.checksumType().equals(\"sha1\") && !fileInfo.checksumType().equals(\"sha256\") && !fileInfo.checksumType().equals(\"md5\")\n    throw new IOException(\"Unsupported checksum type: \" + fileInfo.checksumType());\n// after\n&& !SUPPORTED_CHECKSUMS.contains(fileInfo.checksumType().toLowerCase(Locale.ROOT)) // SUPPORTED_CHECKSUMS = Set.of(\"sha1\",\"sha256\",\"md5\",\"sha512\")","handlingStrategy":"validation","validationCode":"Set<String> supported = Set.of(\"sha1\", \"sha256\", \"md5\");\nString type = fileInfo.checksumType();\nif (StringUtils.isNotBlank(type) && !supported.contains(type.toLowerCase(Locale.ROOT))) {\n    // skip in-app download; use manual install path\n}","typeGuard":null,"tryCatchPattern":"try {\n    downloadJava(version);\n} catch (IOException e) {\n    if (e.getMessage().startsWith(\"Unsupported checksum type:\")) {\n        offerManualDownloadDialog();\n    } else throw e;\n}","preventionTips":["Keep HMCL updated so new upstream checksum algorithms are supported","Check the Disco response's checksumType field before starting large downloads","Prefer distributions known to report sha1/sha256/md5 checksums"],"tags":["checksum","download","api","java"],"backgroundTag":"invalid-enum-value","analyzedSha":"24702dc5a0214034f4c27166d5fd30cad08cec19","analyzedAt":"2026-09-10T12:36:46.680Z","contentChangedAt":"2026-09-10T12:36:46.680Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}