{"record":{"id":"b34b37f374b2f101","repo":"HMCL-dev/HMCL","slug":"malformed-forge-installer-file-b34b37","errorCode":null,"errorMessage":"Malformed forge installer file","messagePattern":"Malformed forge installer file","errorType":"validation","errorClass":"ArtifactMalformedException","httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/download/forge/ForgeOldInstallTask.java","lineNumber":95,"sourceCode":"            Library forgeLibrary = new Library(installProfile.install().getPath());\n            GameRepository gameRepository = dependencyManager.getGameRepository();\n            Path forgeFile = gameRepository.getLayout().getLibraryFile(manifest.id(), forgeLibrary);\n            Files.createDirectories(forgeFile.getParent());\n\n            ZipEntry forgeEntry = zipFile.getEntry(installProfile.install().getFilePath());\n            try (InputStream is = zipFile.getInputStream(forgeEntry);\n                 OutputStream os = Files.newOutputStream(forgeFile, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)) {\n                is.transferTo(os);\n            }\n\n            setResult(GameInstancePatch.fromManifest(\n                    installProfile.versionInfo(),\n                    GameComponentType.FORGE.getPatchId(),\n                    selfVersion,\n                    GameInstancePatch.PRIORITY_LOADER));\n            dependencies.add(dependencyManager.checkComponentCompletionAsync(installProfile.versionInfo(), true));\n        } catch (ZipException ex) {\n            throw new ArtifactMalformedException(\"Malformed forge installer file\", ex);\n        }\n    }\n}\n","sourceCodeStart":77,"sourceCodeEnd":99,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/download/forge/ForgeOldInstallTask.java#L77-L99","documentation":"ForgeOldInstallTask.execute() wraps its whole install-profile processing in a try block; a java.util.zip.ZipException raised while reading entries from the legacy installer (e.g. extracting the universal forge jar or reading install_profile.json contents) is converted to ArtifactMalformedException(\"Malformed forge installer file\"). The archive itself is unreadable at some point mid-processing.","triggerScenarios":"ZipFile read of the legacy forge installer throws ZipException during entry extraction/parsing inside execute() — truncated central directory, CRC failures, or partial file flushed to disk.","commonSituations":"Interrupted downloads leaving truncated jars; filesystem/disk errors; files corrupted in transit through proxies; cached installer damaged after an earlier crash.","solutions":["Delete the cached installer and re-download it, then compare file size with the official listing","Test archive integrity ('unzip -t installer.jar') to confirm corruption","Check free disk space and exclude the HMCL cache from antivirus scanning","Use a different mirror or network to rule out transfer corruption"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// test archive integrity before install\nProcess p = new ProcessBuilder(\"unzip\", \"-t\", installer.toString()).start();\nif (p.waitFor() != 0) throw new IllegalStateException(\"corrupt zip: \" + installer);","typeGuard":null,"tryCatchPattern":"try { installTask.execute(); } catch (ArtifactMalformedException e) { Files.deleteIfExists(installer); reDownloadFromOfficialMirror(); }","preventionTips":["Verify installer file size/SHA-1 against Forge maven metadata","Avoid interrupted downloads; retry on flaky networks","Exclude launcher cache directories from AV real-time scanning","Clear cache after any crashed or cancelled install"],"tags":["java","zip","corrupt-file","forge-installer"],"backgroundTag":"checksum-mismatch","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"}