{"record":{"id":"93072cafe4fda8ed","repo":"HMCL-dev/HMCL","slug":"forgeversion-mcversion-cannot-be-null","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/ForgeBMCLVersionList.java","lineNumber":197,"sourceCode":"@Override\npublic 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}","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/download/forge/ForgeBMCLVersionList.java#L179-L215","documentation":"Thrown during Gson post-deserialization when a Forge version entry fetched from the BMCLAPI metadata lacks the mcversion field; the JSON payload is malformed or from an incompatible API, so the version list aborts validation.","triggerScenarios":"Parsing a Forge version list entry without 'mcversion' and calling validate().","commonSituations":"Partial mirror responses, custom/generated JSON missing the field, or API schema changes breaking deserialization.","solutions":["Add the 'mcversion' field to the version entry JSON","Catch JsonParseException and skip entries missing mcversion","Re-download the version list from the mirror"],"exampleFix":"// before\n{\"version\": \"47.1.3\", \"files\": [...]} // mcversion missing\nversion.validate();\n// after\n{\"version\": \"47.1.3\", \"mcversion\": \"1.20.1\", \"files\": [...]}\nversion.validate();","handlingStrategy":"validation","validationCode":"if (versionObject.get(\"mcversion\") == null || versionObject.get(\"mcversion\").isJsonNull())\n    throw new JsonParseException(\"ForgeVersion mcversion missing\");","typeGuard":"static boolean hasMcVersion(JsonObject entry) {\n    return entry.get(\"mcversion\") instanceof JsonPrimitive p && p.isString() && !p.getAsString().isBlank();\n}","tryCatchPattern":"try {\n    forgeVersion.validate();\n} catch (JsonParseException e) {\n    LOG.warning(\"Skipping entry with missing mcversion: \" + e.getMessage());\n}","preventionTips":["Include mcversion in any tooling that generates Forge version JSON","Re-fetch the list if entries fail validation","Keep HMCL updated for mirror schema changes"],"tags":["java","forge","json","mirror"],"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"}