{"record":{"id":"88b28638c37492ed","repo":"HMCL-dev/HMCL","slug":"iddownloadinfo-id-can-not-be-null","errorCode":null,"errorMessage":"IdDownloadInfo id can not be null","messagePattern":"IdDownloadInfo id can not be null","errorType":"validation","errorClass":"JsonParseException","httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/game/IdDownloadInfo.java","lineNumber":62,"sourceCode":"    public IdDownloadInfo(String id, String url, String sha1) {\n        this(id, url, sha1, 0);\n    }\n\n    public IdDownloadInfo(String id, String url, String sha1, int size) {\n        super(url, sha1, size);\n        this.id = id;\n    }\n\n    public String getId() {\n        return id;\n    }\n\n    @Override\n    public void validate() throws JsonParseException, TolerableValidationException {\n        super.validate();\n\n        if (StringUtils.isBlank(id))\n            throw new JsonParseException(\"IdDownloadInfo id can not be null\");\n    }\n\n}\n","sourceCodeStart":44,"sourceCodeEnd":66,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/game/IdDownloadInfo.java#L44-L66","documentation":"IdDownloadInfo.validate() rejects a download-info entry whose id field is blank/null when a JSON version manifest is parsed. This library throws it because the id is the key used to build download URLs; without it the artifact cannot be located.","triggerScenarios":"Deserializing a version/library asset JSON where a download object has no 'id' member or an empty-string id, then calling validate() as part of the version parsing pipeline.","commonSituations":"Hand-edited or truncated Minecraft version JSON, third-party launcher configs with incomplete library metadata, upstream version manifests changed or pruned.","solutions":["Check the JSON source and fill in the missing id field for the affected entry","Re-download a pristine version JSON from the official manifest URL instead of a corrupted local copy","Fix the third-party tool that generated the partial download metadata","Wrap parsing in error handling and skip/re-fetch the offending entry"],"exampleFix":"// before\n{\"name\": \"something.jar\", \"url\": \"https://...\"}\n// after\n{\"id\": \"something\", \"name\": \"something.jar\", \"url\": \"https://...\"}","handlingStrategy":"validation","validationCode":"if (downloadInfo == null || downloadInfo.getId() == null || downloadInfo.getId().isBlank()) {\n    throw new IllegalArgumentException(\"entry must have a non-blank id before parsing\");\n}","typeGuard":"static boolean hasId(JsonObject obj) {\n    return obj.has(\"id\") && obj.get(\"id\").isJsonPrimitive() && !obj.get(\"id\").getAsString().isBlank();\n}","tryCatchPattern":"try {\n    version.validate();\n} catch (JsonParseException e) {\n    if (e.getMessage().contains(\"id can not be null\")) {\n        // re-fetch or repair the version JSON\n    } else throw e;\n}","preventionTips":["Never hand-edit version JSON download entries","Re-fetch manifests from the official source after corruption","Schema-validate version JSONs before loading","Log the offending entry path to locate the bad object quickly"],"tags":["json","validation","minecraft"],"backgroundTag":"empty-required-field","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"}