{"record":{"id":"7b7b9f2b26d12f71","repo":"HMCL-dev/HMCL","slug":"illegal-json-patch","errorCode":null,"errorMessage":"Illegal Json-Patch: ","messagePattern":"Illegal Json-Patch: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/modpack/multimc/MultiMCInstancePatch.java","lineNumber":197,"sourceCode":"        // TODO: Maybe new ArrayList(new LinkedHashSet(original)) ?\n\n        Set<T> values = new HashSet<>();\n        List<T> result = new ArrayList<>();\n\n        for (T item : original) {\n            if (values.add(item)) {\n                result.add(item);\n            }\n        }\n\n        return result;\n    }\n\n    public static MultiMCInstancePatch read(String componentID, String text) {\n        try {\n            return JsonUtils.fromNonNullJson(text, MultiMCInstancePatch.class);\n        } catch (JsonParseException e) {\n            throw new IllegalArgumentException(\"Illegal Json-Patch: \" + componentID);\n        }\n    }\n\n    public static final class ResolvedInstance {\n        private final GameInstanceManifest manifest;\n\n        private final String gameVersion;\n\n        private final Library mainJar;\n\n        private final List<String> jarModFileNames;\n        private final List<Library> mavenOnlyFiles;\n\n        public ResolvedInstance(GameInstanceManifest manifest, String gameVersion, Library mainJar, List<String> jarModFileNames, List<Library> mavenOnlyFiles) {\n            this.manifest = manifest;\n            this.gameVersion = gameVersion;\n            this.mainJar = mainJar;\n            this.jarModFileNames = jarModFileNames;","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/modpack/multimc/MultiMCInstancePatch.java#L179-L215","documentation":"MultiMCInstancePatch.read wraps JsonParseException thrown while deserializing a MultiMC component patch JSON, rethrowing it as IllegalArgumentException identifying the offending component ID. It indicates the patch text is not valid JSON or does not match the MultiMCInstancePatch schema.","triggerScenarios":"Reading a component JSON file (e.g. from mmc-pack.json or patches/ directory) that is malformed or has an unexpected structure, via MultiMCInstancePatch.read(componentID, text).","commonSituations":"Corrupted MultiMC/PollyMC instances; hand-edited component files; mmc-pack.json entries with invalid embedded JSON.","solutions":["Fix or regenerate the offending component JSON identified by componentID","Re-download or re-import the MultiMC instance archive","Validate the JSON with a linter before placing it in the instance"],"exampleFix":"// before\nString text = \"{ not valid json }\";\nMultiMCInstancePatch.read(\"net.minecraft\", text);\n// after\nString text = \"{\\\"formatVersion\\\":1,\\\"uid\\\":\\\"net.minecraft\\\"}\"; // valid patch JSON\nMultiMCInstancePatch.read(\"net.minecraft\", text);","handlingStrategy":"try-catch","validationCode":"try { JsonUtils.fromNonNullJson(text, MultiMCInstancePatch.class); } catch (JsonParseException e) { /* reject component before calling read */ }","typeGuard":null,"tryCatchPattern":"try { patch = MultiMCInstancePatch.read(id, text); } catch (IllegalArgumentException e) { LOG.warning(\"Bad patch for \" + id, e); skipOrAbort(); }","preventionTips":["Validate component JSON with a linter after editing","Re-download instance archives that fail to parse","Never paste non-JSON text into component files"],"tags":["multimc","json","patch","illegal-argument"],"backgroundTag":"json-parse-error","analyzedSha":"24702dc5a0214034f4c27166d5fd30cad08cec19","analyzedAt":"2026-09-10T12:36:46.680Z","contentChangedAt":"2026-09-10T12:36:46.680Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}