{"record":{"id":"db52c67ef6c32b82","repo":"HMCL-dev/HMCL","slug":"file-modfile-is-not-a-liteloader-mod","errorCode":null,"errorMessage":"\"File \" + modFile + \" is not a LiteLoader mod.\"","messagePattern":"\"File \" \\+ modFile \\+ \" is not a LiteLoader mod\\.\"","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/addon/meta/LiteModMetadata.java","lineNumber":116,"sourceCode":"        return modpackName;\n    }\n\n    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":98,"sourceCodeEnd":125,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/addon/meta/LiteModMetadata.java#L98-L125","documentation":"LiteModMetadata.fromFile requires the archive to contain a `litemod.json` entry at its root, which is the marker of a LiteLoader mod. If absent, an IOException declares the file is not a LiteLoader mod.","triggerScenarios":"Calling LiteModMetadata.fromFile with a ZipFileTree for a jar that has no `litemod.json` entry (plain Forge/Fabric mod or non-mod file).","commonSituations":"Scanning a mixed mods folder where files of other loaders are probed for LiteLoader metadata; misnamed `.litemod` files that are really jars of another type.","solutions":["Confirm the file is actually a LiteLoader mod (contains `litemod.json`)","Only call fromFile after checking tree.getEntry(\"litemod.json\") != null","Try parsing with the metadata parser matching the file's actual mod loader"],"exampleFix":"// before\nLiteModMetadata.fromFile(modManager, modFile, tree);\n// after\nif (tree.getEntry(\"litemod.json\") != null) {\n    LiteModMetadata.fromFile(modManager, modFile, tree);\n}","handlingStrategy":"type-guard","validationCode":"if (tree.getEntry(\"litemod.json\") == null) {\n    // not a LiteLoader mod; dispatch to another parser\n}","typeGuard":"boolean isLiteLoaderMod(ZipFileTree tree) {\n    return tree.getEntry(\"litemod.json\") != null;\n}","tryCatchPattern":"try {\n    LiteModMetadata.fromFile(modManager, modFile, tree);\n} catch (IOException e) {\n    if (e.getMessage().contains(\"is not a LiteLoader mod\")) tryOtherParser(modFile, tree);\n}","preventionTips":["Detect loader type by probing known marker files (litemod.json, fabric.mod.json, quilt.mod.json, mods.toml, mcmod.info) before parsing","Don't assume file extension implies mod type"],"tags":["java","io","mod-metadata","liteloader"],"backgroundTag":"resource-not-found","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"}