{"record":{"id":"624b4ed1d7d92832","repo":"HMCL-dev/HMCL","slug":"minecraftinstanceconfiguration-missing-type","errorCode":null,"errorMessage":"MinecraftInstanceConfiguration missing `type`","messagePattern":"MinecraftInstanceConfiguration missing `type`","errorType":"validation","errorClass":"JsonParseException","httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/modpack/ModpackConfiguration.java","lineNumber":94,"sourceCode":"\n    public ModpackConfiguration<T> setOverrides(List<FileInformation> overrides) {\n        return new ModpackConfiguration<>(manifest, type, name, version, overrides);\n    }\n\n    public ModpackConfiguration<T> setVersion(String version) {\n        return new ModpackConfiguration<>(manifest, type, name, version, overrides);\n    }\n\n    public List<FileInformation> getOverrides() {\n        return Collections.unmodifiableList(overrides);\n    }\n\n    @Override\n    public void validate() throws JsonParseException {\n        if (manifest == null)\n            throw new JsonParseException(\"MinecraftInstanceConfiguration missing `manifest`\");\n        if (type == null)\n            throw new JsonParseException(\"MinecraftInstanceConfiguration missing `type`\");\n    }\n\n    @Immutable\n    public static class FileInformation implements Validation {\n        private final String path; // relative\n        private final String hash;\n        private final String downloadURL;\n\n        public FileInformation() {\n            this(null, null);\n        }\n\n        public FileInformation(String path, String hash) {\n            this(path, hash, null);\n        }\n\n        public FileInformation(String path, String hash, String downloadURL) {\n            this.path = path;","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/modpack/ModpackConfiguration.java#L76-L112","documentation":"ModpackConfiguration.validate() also requires the top-level `type` field to identify the configuration kind (e.g. \"minecraftInstance\"). It throws JsonParseException(\"MinecraftInstanceConfiguration missing `type`\") when type is null after JSON deserialization, so the modpack's format cannot be determined.","triggerScenarios":"Calling validate() on a ModpackConfiguration parsed from modpack.json without the `type` key, or with type explicitly set to null.","commonSituations":"Hand-written modpack.json omitting the type discriminator; upgrading from an older modpack format that lacked type; copy-pasting only the manifest section into a new file; key renamed/case-mismatched.","solutions":["Add \"type\": \"minecraftInstance\" to the top level of modpack.json.","Re-export the modpack with the official packaging tool so all required fields are written.","Check the key spelling/casing is exactly `type`.","Validate the full modpack.json against the current modpack schema before distribution."],"exampleFix":"// before (modpack.json)\n// { \"manifest\": { \"name\": \"MyPack\" } }\n// after\n// { \"type\": \"minecraftInstance\", \"manifest\": { \"name\": \"MyPack\" } }","handlingStrategy":"validation","validationCode":"try {\n    ModpackConfiguration cfg = GSON.fromJson(json, ModpackConfiguration.class);\n    cfg.validate();\n} catch (JsonParseException e) {\n    // modpack.json missing type — reject or regenerate the pack\n}","typeGuard":null,"tryCatchPattern":"try {\n    config.validate();\n} catch (JsonParseException e) {\n    if (e.getMessage().contains(\"missing `type`\")) {\n        // add \"type\": \"minecraftInstance\" or re-export the pack\n    }\n}","preventionTips":["Include the `type` discriminator in every modpack.json you author","Schema-validate modpack.json in CI before publishing packs","Migrate old-format packs to the current format before import"],"tags":["modpack","json","validation","missing-field"],"backgroundTag":"missing-required-config-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"}