{"record":{"id":"368c7dfe30f55e38","repo":"HMCL-dev/HMCL","slug":"forgeversion-mcversion-cannot-be-null-368c7d","errorCode":null,"errorMessage":"ForgeVersion mcversion cannot be null","messagePattern":"ForgeVersion mcversion cannot be null","errorType":"validation","errorClass":"JsonParseException","httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/download/forge/ForgeVersion.java","lineNumber":92,"sourceCode":"        return build;\n    }\n\n    public long getModified() {\n        return modified;\n    }\n\n    public String[][] getFiles() {\n        return files;\n    }\n\n    @Override\n    public void validate() throws JsonParseException {\n        if (files == null)\n            throw new JsonParseException(\"ForgeVersion files cannot be null\");\n        if (version == null)\n            throw new JsonParseException(\"ForgeVersion version cannot be null\");\n        if (mcversion == null)\n            throw new JsonParseException(\"ForgeVersion mcversion cannot be null\");\n    }\n\n}\n","sourceCodeStart":74,"sourceCodeEnd":96,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/download/forge/ForgeVersion.java#L74-L96","documentation":"ForgeVersion.validate() throws this JsonParseException when the 'mcversion' field (the target Minecraft version) is null. HMCL uses mcversion to match the Forge installer to a Minecraft version, so the field is mandatory.","triggerScenarios":"validate() on a ForgeVersion deserialized from JSON missing 'mcversion' — malformed feed entry, corrupted cache, or schema drift in the Forge metadata source.","commonSituations":"Third-party mirror returned stripped metadata, download interrupted mid-write, or an old cached feed no longer matches the current parser expectations.","solutions":["Re-download the Forge version JSON; clear any HMCL cache for that Forge entry.","Confirm the JSON's 'mcversion' matches the Minecraft version you are installing Forge for.","Try a different download source/mirror or update HMCL."],"exampleFix":"// before\nForgeVersion v = JsonUtils.fromJson(json, ForgeVersion.class);\nv.validate();\n// after\nForgeVersion v = JsonUtils.fromJson(json, ForgeVersion.class);\nif (v == null || v.getMcversion() == null) {\n    v = refetchForgeVersion(versionId);\n}\nv.validate();","handlingStrategy":"validation","validationCode":"if (versionJson == null || !versionJson.has(\"mcversion\")) refetch();","typeGuard":"boolean hasMcVersion(ForgeVersion v) { return v != null && v.getMcversion() != null; }","tryCatchPattern":"try { v.validate(); } catch (JsonParseException e) { refetchForgeVersion(); }","preventionTips":["Ensure the Forge build targets the expected Minecraft version","Verify downloads completed (size/checksum)","Clear stale caches when switching mirrors"],"tags":["json","forge","validation"],"backgroundTag":"schema-validation-failed","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"}