HMCL-dev/HMCL · error · IOException
Malformed modpack configuration:
Error message
Malformed modpack configuration:
What it means
Thrown during Mcbbs modpack export when the instance's Minecraft version cannot be resolved to a valid GameVersionNumber. The exporter must write a valid gameVersion into the mcbbs manifest, so an unparseable/unknown version is a hard stop (IOException). This typically happens when the instance's version JSON is missing, malformed, or inherits from a broken base.
Solutions
- Open the instance and verify its game version is set and valid in the instance settings
- Check the instance's version JSON (versions/<id>/<id>.json) for a valid id and complete inheritance chain
- Re-download or re-create the instance if its version JSON is corrupted
- Export a different, healthy instance to confirm the exporter works
Example fix
// broken instance json (no id / bad version)
{"inheritsFrom": "1.7.10-missing"}
// after: point to an existing installed version
{"id": "1.7.10", "inheritsFrom": "1.7.10"} Defensive patterns
Strategy: validation
Validate before calling
GameVersionNumber v = instance.getVersion();
if (v == GameVersionNumber.unknown())
throw new IllegalStateException("Fix instance version before exporting: " + instanceId); Type guard
if (instance.getVersion() != GameVersionNumber.unknown()) { /* safe to export */ } Try / catch
try { task.execute(); } catch (IOException e) { if (e.getMessage().startsWith("Cannot parse the version")) { /* prompt user to fix instance version */ } else throw e; } Prevention
- Verify the instance launches correctly before exporting
- Keep inherited version chains intact (don't delete parent versions)
- Validate instance JSON after manual edits
When it happens
Trigger: Calling McbbsModpackExportTask.execute() on an instance whose version cannot be parsed by GameVersionNumber — e.g. instance JSON has no/invalid id or inheritsVersion chain is broken, so instance.getVersion() returns GameVersionNumber.unknown().
Common situations: Exporting a corrupted or manually edited instance; exporting an instance created from a damaged version JSON; exporting an instance whose inherited parent version was deleted; exporting vanilla/packaged instances with non-standard version ids.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Cannot parse the version of
- Unsupported icon file:
- Missing hmcl.lwjgl-unsafe-agent.version attribute
- Invalid library path:
- /assets/
AI-assisted analysis of HMCL-dev/HMCL@24702dc5a0 (2026-09-10).
Data as JSON: /api/errors/da60eaebae06c35e.
Report an issue: GitHub.
Appendix: source
Thrown at HMCL/src/main/java/org/jackhuang/hmcl/game/HMCLGameInstance.java:156
///
/// @return whether [#getModpackConfigurationFile()] exists
public boolean isModpack() {
return Files.exists(getModpackConfigurationFile());
}
/// Reads this instance's HMCL modpack configuration.
///
/// @return the parsed configuration, or `null` when the file does not exist
/// @throws IOException if the configuration cannot be read
public @Nullable ModpackConfiguration<?> readModpackConfiguration() throws IOException {
Path file = getModpackConfigurationFile();
if (Files.notExists(file)) {
return null;
}
try {
return JsonUtils.fromJsonFile(file, ModpackConfiguration.class);
} catch (JsonParseException e) {
throw new IOException("Malformed modpack configuration: " + file, e);
}
}
@Override
public Path getRunDirectory() {
return getRepository().computeRunDirectory(getId(), isModpack(), getSettings());
}
/// Returns the loaded instance-local game settings, loading them while this instance is current.
///
/// @return the settings, or `null` when no local settings exist after loading
public @Nullable GameSettings.Instance getSettings() {
ensureGameSettingsLoaded();
return gameSettings;
}
/// Returns the instance-local game settings, creating an empty settings object when absent.
///View on GitHub (pinned to 24702dc5a0)