{"record":{"id":"ff00751143fef022","repo":"HMCL-dev/HMCL","slug":"gameremoteversions-versions-cannot-be-null","errorCode":null,"errorMessage":"GameRemoteVersions.versions cannot be null","messagePattern":"GameRemoteVersions\\.versions cannot be null","errorType":"validation","errorClass":"JsonParseException","httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/download/game/GameRemoteVersions.java","lineNumber":41,"sourceCode":"import org.jackhuang.hmcl.util.gson.JsonSerializable;\nimport org.jackhuang.hmcl.util.gson.Validation;\n\nimport java.util.List;\n\n/**\n *\n * @author huangyuhui\n */\n@Immutable\n@JsonSerializable\npublic record GameRemoteVersions(\n        @SerializedName(\"versions\") List<GameRemoteVersionInfo> versions,\n        @SerializedName(\"latest\") GameRemoteLatestVersions latest) implements Validation {\n\n    @Override\n    public void validate() throws JsonParseException {\n        if (versions == null)\n            throw new JsonParseException(\"GameRemoteVersions.versions cannot be null\");\n    }\n}\n","sourceCodeStart":23,"sourceCodeEnd":44,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/download/game/GameRemoteVersions.java#L23-L44","documentation":"GameRemoteVersions is the deserialized model of Mojang's version manifest (version_manifest_v2.json). Its validate() enforces that the top-level `versions` array parsed from the JSON is present. If the server response lacked the field (or Gson left it null), the data is considered unusable and a JsonParseException is thrown so the version list refresh fails fast instead of producing an empty/broken game version list.","triggerScenarios":"Parsing a Mojang version manifest JSON whose `versions` key is absent or deserialized to null, typically when GameRepository / RemoteVersionList calls GameRemoteVersions.validate() after JsonUtils deserialization.","commonSituations":"Network middleboxes or mirrors returning truncated/partial JSON; Mojang changing the manifest schema; a proxy or cache serving an error page that still parses as JSON without `versions`; stale/corrupted cached manifest.","solutions":["Verify the manifest URL is reachable and returns the official version_manifest_v2.json (check with curl or browser).","Clear HMCL's cached version list / download data and refresh the game list again.","Disable HTTP proxies/interception or switch mirror/download provider if a mirror serves incomplete JSON.","Retry later; if Mojang temporarily altered the schema, updating HMCL to a newer build that adapts to the new format fixes it."],"exampleFix":"// Not caller-fixable in code; guard at call site:\ntry {\n    GameRemoteVersions v = JsonUtils.fromJson(json, GameRemoteVersions.class);\n    v.validate();\n} catch (JsonParseException e) {\n    LOG.warning(\"Version manifest missing 'versions', falling back to cached list\", e);\n}","handlingStrategy":"validation","validationCode":"org.w3c.dom // pre-check the manifest JSON before use\nif (!json.contains(\"\\\"versions\\\"\")) {\n    throw new IllegalStateException(\"Manifest missing 'versions' — mirror/network problem\");\n}","typeGuard":"if (remoteVersions == null || remoteVersions.getVersions() == null) { /* skip/refresh */ }","tryCatchPattern":"try { versions.validate(); } catch (JsonParseException e) { LOG.warning(\"Bad version manifest: \" + e.getMessage(), e); /* fall back to cached list */ }","preventionTips":["Use the official Mojang manifest URL or a known-good mirror.","Clear cached version lists when they look empty.","Retry list refresh on transient network failures before surfacing the error."],"tags":["json","validation","network","minecraft"],"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-15T23:17:13.987Z"}