HMCL-dev/HMCL · error · JsonParseException
MinecraftInstanceConfiguration missing `type`
Error message
MinecraftInstanceConfiguration missing `type`
What it means
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.
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.
Example fix
// before (modpack.json)
// { "manifest": { "name": "MyPack" } }
// after
// { "type": "minecraftInstance", "manifest": { "name": "MyPack" } } Defensive patterns
Strategy: validation
Validate before calling
try {
ModpackConfiguration cfg = GSON.fromJson(json, ModpackConfiguration.class);
cfg.validate();
} catch (JsonParseException e) {
// modpack.json missing type — reject or regenerate the pack
} Try / catch
try {
config.validate();
} catch (JsonParseException e) {
if (e.getMessage().contains("missing `type`")) {
// add "type": "minecraftInstance" or re-export the pack
}
} Prevention
- 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
When it happens
Trigger: Calling validate() on a ModpackConfiguration parsed from modpack.json without the `type` key, or with type explicitly set to null.
Common situations: 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.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- MinecraftInstanceConfiguration missing `manifest`
- ServerModpackManifest.fileApi cannot be blank
- ServerModpackManifest.files cannot be null
- FileInformation missing `path`.
- FileInformation missing file hash code.
AI-assisted analysis of HMCL-dev/HMCL@24702dc5a0 (2026-09-10).
Data as JSON: /api/errors/624b4ed1d7d92832.
Report an issue: GitHub.
Appendix: source
Thrown at HMCLCore/src/main/java/org/jackhuang/hmcl/modpack/ModpackConfiguration.java:94
public ModpackConfiguration<T> setOverrides(List<FileInformation> overrides) {
return new ModpackConfiguration<>(manifest, type, name, version, overrides);
}
public ModpackConfiguration<T> setVersion(String version) {
return new ModpackConfiguration<>(manifest, type, name, version, overrides);
}
public List<FileInformation> getOverrides() {
return Collections.unmodifiableList(overrides);
}
@Override
public void validate() throws JsonParseException {
if (manifest == null)
throw new JsonParseException("MinecraftInstanceConfiguration missing `manifest`");
if (type == null)
throw new JsonParseException("MinecraftInstanceConfiguration missing `type`");
}
@Immutable
public static class FileInformation implements Validation {
private final String path; // relative
private final String hash;
private final String downloadURL;
public FileInformation() {
this(null, null);
}
public FileInformation(String path, String hash) {
this(path, hash, null);
}
public FileInformation(String path, String hash, String downloadURL) {
this.path = path;View on GitHub (pinned to 24702dc5a0)