{"record":{"id":"04a7fd39ff05ecf8","repo":"HMCL-dev/HMCL","slug":"invalid-metadata-file-jarinjarmetadata","errorCode":null,"errorMessage":"\"Invalid metadata file: \" + jarInJarMetadata","messagePattern":"\"Invalid metadata file: \" \\+ jarInJarMetadata","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/addon/meta/ForgeNewModMetadata.java","lineNumber":278,"sourceCode":"            manifest = new Manifest(input);\n        }\n\n        List<ZipArchiveEntry> embeddedModFiles = List.of();\n\n        String embeddedDependenciesMod = manifest.getMainAttributes().getValue(\"Embedded-Dependencies-Mod\");\n        if (embeddedDependenciesMod != null) {\n            ZipArchiveEntry embeddedModFile = tree.getEntry(embeddedDependenciesMod);\n            if (embeddedModFile == null) {\n                LOG.warning(\"Missing embedded-dependencies-mod: \" + embeddedDependenciesMod);\n                throw new IOException();\n            }\n            embeddedModFiles = List.of(embeddedModFile);\n        } else {\n            ZipArchiveEntry jarInJarMetadata = tree.getEntry(\"META-INF/jarjar/metadata.json\");\n            if (jarInJarMetadata != null) {\n                JarInJarMetadata metadata = JsonUtils.fromJsonFully(tree.getInputStream(jarInJarMetadata), JarInJarMetadata.class);\n                if (metadata == null)\n                    throw new IOException(\"Invalid metadata file: \" + jarInJarMetadata);\n\n                metadata.validate();\n\n                embeddedModFiles = new ArrayList<>();\n                for (EmbeddedJarMetadata jar : metadata.jars) {\n                    ZipArchiveEntry path = tree.getEntry(jar.path);\n                    if (path != null) {\n                        embeddedModFiles.add(path);\n                    } else {\n                        LOG.warning(\"Missing embedded-dependencies-mod: \" + jar.path);\n                    }\n                }\n            }\n        }\n\n        if (embeddedModFiles.isEmpty()) {\n            throw new IOException(\"Missing embedded mods\");\n        }","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/addon/meta/ForgeNewModMetadata.java#L260-L296","documentation":"Thrown by ForgeNewModMetadata.fromEmbeddedMod when META-INF/jarjar/metadata.json exists but deserializes to null, so HMCL cannot read the Forge jar-in-jar embedding manifest that lists the nested dependency jars.","triggerScenarios":"fromFile -> fromEmbeddedMod: tree.getEntry(\"META-INF/jarjar/metadata.json\") is non-null but JsonUtils.fromJsonFully(stream, JarInJarMetadata.class) returns null (e.g. the stream decodes to JSON null or the type cannot be populated).","commonSituations":"A mod jar with a truncated, empty, or 'null' jarjar/metadata.json; a metadata.json written by an incompatible Forge jarjar version; jar corruption from a bad download.","solutions":["Open META-INF/jarjar/metadata.json in the jar and check it is valid, non-empty JSON with a jars array.","Re-download the mod jar — an empty/truncated metadata.json indicates corruption.","Rebuild the mod with a current ForgeGradle/Loom version so jarjar metadata is emitted correctly.","If the file is legitimately unreadable, remove the jar; HMCL cannot resolve its embedded dependencies."],"exampleFix":"// before (metadata.json)\nnull\n// after\n{ \"jars\": [ { \"identifier\": { \"group\": \"com.example\", \"artifact\": \"dep\" }, \"version\": \"1.0\", \"path\": \"META-INF/jarjar/dep-1.0.jar\" } ] }","handlingStrategy":"validation","validationCode":"ZipArchiveEntry jarjar = tree.getEntry(\"META-INF/jarjar/metadata.json\");\nif (jarjar != null) {\n    String text = tree.readTextEntry(jarjar);\n    if (text == null || text.isBlank() || text.trim().equals(\"null\")) {\n        throw new IllegalArgumentException(\"corrupt META-INF/jarjar/metadata.json\");\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    LocalModFile mod = ForgeNewModMetadata.fromFile(modManager, modFile, tree, type);\n} catch (IOException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Invalid metadata file\")) {\n        LOG.warning(\"Corrupt jarjar metadata.json in \" + modFile);\n    }\n}","preventionTips":["Validate jarjar/metadata.json is non-empty, valid JSON before parsing","Re-download mod jars that arrive with empty metadata files","Build with a current ForgeGradle/Loom so jarjar metadata is generated correctly"],"tags":["minecraft","forge","jar-in-jar","json","null-deserialization"],"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-15T23:17:13.987Z"}