{"record":{"id":"92214a956b25f688","repo":"HMCL-dev/HMCL","slug":"json-patch-isn-t-a-file","errorCode":null,"errorMessage":"Json-Patch isn't a file: ","messagePattern":"Json-Patch isn't a file: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/modpack/multimc/MultiMCModpackInstallTask.java","lineNumber":242,"sourceCode":"\n            String mcVersion = null;\n            for (MultiMCManifest.MultiMCManifestComponent component : components) {\n                if (MultiMCComponents.getComponent(component.getUid()) == GameComponentType.GAME) {\n                    mcVersion = component.getVersion();\n                    break;\n                }\n            }\n            if (mcVersion == null) {\n                throw new IllegalStateException(\"Cannot load modpacks without Minecraft.\");\n            }\n\n            for (MultiMCManifest.MultiMCManifestComponent component : components) {\n                String componentID = Objects.requireNonNull(component.getUid(), \"Component ID\");\n                Path patchPath = root.resolve(String.format(\"patches/%s.json\", componentID));\n\n                if (Files.exists(patchPath)) {\n                    if (!Files.isRegularFile(patchPath)) {\n                        throw new IllegalArgumentException(\"Json-Patch isn't a file: \" + componentID);\n                    }\n\n                    MultiMCInstancePatch patch = MultiMCInstancePatch.read(componentID, Files.readString(patchPath));\n                    patches.add(Task.supplyAsync(() -> patch)); // TODO: Task.completed has unclear compatibility issue.\n                } else {\n                    patches.add(\n                            new GetTask(MultiMCComponents.getMetaURL(componentID, component.getVersion(), mcVersion))\n                                    .thenApplyAsync(s -> MultiMCInstancePatch.read(componentID, s))\n                    );\n                }\n            }\n            dependents.add(new MMCInstancePatchesAssembleTask(patches, mcVersion));\n        }\n    }\n\n    private static final class MMCInstancePatchesAssembleTask extends Task<List<MultiMCInstancePatch>> {\n        private final List<Task<MultiMCInstancePatch>> patches;\n        private final String mcVersion;","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/modpack/multimc/MultiMCModpackInstallTask.java#L224-L260","documentation":"Each component's local patch is expected at patches/<uid>.json inside the modpack. If that path exists but is not a regular file (e.g. a directory named like the patch inside the extracted/zip filesystem), HMCL refuses to read it rather than failing later with a confusing I/O error.","triggerScenarios":"preExecute resolves patches/<uid>.json inside the modpack filesystem; Files.exists is true but Files.isRegularFile is false, typically because a directory with that name exists in the archive.","commonSituations":"A malformed or hand-modified modpack zip where patches/ contains directories instead of JSON files; filesystem quirks after re-zipping the pack.","solutions":["Open the modpack zip and replace the patches/<uid>.json directory with a proper JSON patch file.","Re-download or re-export the modpack archive.","Remove the bogus entry so HMCL fetches the patch from the component metadata server instead."],"exampleFix":"// inside modpack zip\n// before: patches/net.minecraft/          (directory)\n// after:  patches/net.minecraft.json      (regular file)","handlingStrategy":"validation","validationCode":"Path p = root.resolve(\"patches/\" + uid + \".json\");\nboolean usable = Files.isRegularFile(p);","typeGuard":null,"tryCatchPattern":"try { task.run(); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"Json-Patch isn't a file\")) { /* repack the modpack */ } }","preventionTips":["Inspect patches/ contents when re-zipping modpacks","Never replace patch JSON files with directories","Prefer launcher exports over manual repacks"],"tags":["java","modpack","zip","patch"],"backgroundTag":"invalid-argument-value","analyzedSha":"24702dc5a0214034f4c27166d5fd30cad08cec19","analyzedAt":"2026-09-10T12:36:46.680Z","contentChangedAt":"2026-09-10T12:36:46.680Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}