{"record":{"id":"d9432dc1ddf41288","repo":"HMCL-dev/HMCL","slug":"forgeversion-version-cannot-be-null-d9432d","errorCode":null,"errorMessage":"ForgeVersion version cannot be null","messagePattern":"ForgeVersion version cannot be null","errorType":"validation","errorClass":"JsonParseException","httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/download/forge/ForgeVersion.java","lineNumber":90,"sourceCode":"\n    public int getBuild() {\n        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":72,"sourceCodeEnd":96,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/download/forge/ForgeVersion.java#L72-L96","documentation":"ForgeVersion.validate() throws this JsonParseException when the 'version' field of the Forge install-profile JSON is null. HMCL needs the Forge version identifier to name and resolve the installed profile; a record without it is invalid.","triggerScenarios":"validate() is invoked on a ForgeVersion whose JSON lacked the 'version' field, e.g. an unexpected upstream schema or a hand-edited/corrupted local file.","commonSituations":"Upstream Forge metadata format changed, a mirror returned an incomplete entry, or a locally cached JSON was edited/truncated.","solutions":["Delete the cached Forge version JSON and re-download from the remote repository.","Verify the JSON actually contains a 'version' string matching the requested Forge build.","Update HMCL or switch the download mirror (e.g. BMCLAPI vs official Forge meta)."],"exampleFix":"// before\nForgeVersion v = JsonUtils.fromJson(json, ForgeVersion.class);\nv.validate();\n// after\nForgeVersion v = JsonUtils.fromJson(json, ForgeVersion.class);\nif (v == null || v.getVersion() == null) {\n    v = refetchForgeVersion(versionId);\n}\nv.validate();","handlingStrategy":"validation","validationCode":"if (versionJson == null || !versionJson.has(\"version\")) refetch();","typeGuard":"boolean hasVersion(ForgeVersion v) { return v != null && v.getVersion() != null; }","tryCatchPattern":"try { v.validate(); } catch (JsonParseException e) { refetchForgeVersion(); }","preventionTips":["Cache Forge JSON with integrity checks","Compare cached 'version' against the requested build id","Pin a known-good mirror"],"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"}