{"record":{"id":"6f6afae77a5ba190","repo":"HMCL-dev/HMCL","slug":"mod-modfile-litemod-json-is-malformed","errorCode":null,"errorMessage":"\"Mod \" + modFile + \" `litemod.json` is malformed.\"","messagePattern":"\"Mod \" \\+ modFile \\+ \" `litemod\\.json` is malformed\\.\"","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/addon/meta/LiteModMetadata.java","lineNumber":119,"sourceCode":"    public String getModpackVersion() {\n        return modpackVersion;\n    }\n\n    public String getCheckUpdateUrl() {\n        return checkUpdateUrl;\n    }\n\n    public String getUpdateURI() {\n        return updateURI;\n    }\n\n    public static LocalModFile fromFile(ModManager modManager, Path modFile, ZipFileTree tree) throws IOException, JsonParseException {\n        ZipArchiveEntry entry = tree.getEntry(\"litemod.json\");\n        if (entry == null)\n            throw new IOException(\"File \" + modFile + \" is not a LiteLoader mod.\");\n        LiteModMetadata metadata = JsonUtils.fromJsonFully(tree.getInputStream(entry), LiteModMetadata.class);\n        if (metadata == null)\n            throw new IOException(\"Mod \" + modFile + \" `litemod.json` is malformed.\");\n        return new LocalModFile(modManager, modManager.getLocalMod(metadata.getName(), ModLoaderType.LITE_LOADER), modFile, metadata.getName(), new LocalAddonFile.Description(metadata.getDescription()), metadata.getAuthor(),\n                metadata.getVersion(), metadata.getGameVersion(), metadata.getUpdateURI(), \"\");\n    }\n\n}\n","sourceCodeStart":101,"sourceCodeEnd":125,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/addon/meta/LiteModMetadata.java#L101-L125","documentation":"After locating `litemod.json`, LiteModMetadata.fromFile deserializes it with JsonUtils.fromJsonFully. A null result (JSON `null`, blank stream, or lenient parse yielding nothing) triggers this IOException because no LiteLoader metadata exists.","triggerScenarios":"Calling LiteModMetadata.fromFile on an archive whose `litemod.json` is empty, contains only `null`, or otherwise deserializes to null.","commonSituations":"Truncated/corrupted mod downloads; hand-created `litemod.json` left blank; packaging step that wrote a zero-byte entry.","solutions":["Verify `litemod.json` content is a complete JSON object with name/version/gameVersion","Re-download or rebuild the mod","Remove the broken file from the mods folder"],"exampleFix":"// before (empty litemod.json)\n\n// after\n{ \"name\": \"Example\", \"mcversion\": \"1.12.2\", \"version\": \"1.0\" }","handlingStrategy":"try-catch","validationCode":"var e = tree.getEntry(\"litemod.json\");\nString s = new String(tree.getInputStream(e).readAllBytes(), StandardCharsets.UTF_8);\nif (s.isBlank() || s.trim().equals(\"null\")) throw new IllegalStateException(\"litemod.json blank\");","typeGuard":null,"tryCatchPattern":"try {\n    LiteModMetadata.fromFile(modManager, modFile, tree);\n} catch (IOException | JsonParseException e) {\n    log.warn(\"Malformed litemod.json in \" + modFile, e);\n}","preventionTips":["Verify downloaded files with checksums","Never package an empty litemod.json","Isolate parse failures per mod so scanning continues"],"tags":["java","json","mod-metadata","liteloader"],"backgroundTag":"json-unmarshal-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"}