HMCL-dev/HMCL · error · JsonParseException

Theme is missing the id

Error message

Theme is missing the id

What it means

A sentinel error raised in Theme.fromJson() when the theme must declare an explicit identity (requireIdentity is true) but its JSON object has no 'id' field. It fires for packs where each theme must be addressable by ID; anonymous themes are only tolerated in single-theme packs where requireIdentity is false.

Solutions

  1. Add an 'id' field in package ID format to the theme's JSON entry.
  2. If the theme pack contains only one theme, drop the identity requirement rather than fabricating an ID.
  3. Replace the malformed theme pack with a valid one.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at HMCL/src/main/java/org/jackhuang/hmcl/theme/Theme.java:105 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of HMCL-dev/HMCL@24702dc5a0 (2026-09-10). Data as JSON: /api/errors/83cd6c3b431e3496. Report an issue: GitHub.

Appendix: source

Thrown at HMCL/src/main/java/org/jackhuang/hmcl/theme/Theme.java:105

    /// @return the parsed theme
    /// @throws JsonParseException if required identity fields are missing or malformed
    static Theme fromJson(JsonObject object, boolean requireIdentity) throws JsonParseException {
        Objects.requireNonNull(object);

        @Nullable String id = JsonUtils.getString(object, "id");
        if (id != null) {
            try {
                id = ThemePackManifest.requireThemeId(id);
            } catch (IllegalArgumentException e) {
                if (requireIdentity) {
                    throw new JsonParseException(e);
                }
                LOG.warning("Ignored invalid theme id: " + id, e);
                id = null;
            }
        }
        if (id == null && requireIdentity) {
            throw new JsonParseException("Theme is missing the id");
        }
        @Nullable LocalizedText name;
        try {
            name = LocalizedText.fromJson(object.get("name"));
            if (name != null && name.mayBeEmpty()) {
                throw new JsonParseException("Theme name is empty: " + name);
            }
        } catch (JsonParseException | IllegalArgumentException e) {
            if (requireIdentity) {
                throw e;
            }
            LOG.warning("Ignored invalid theme name", e);
            name = null;
        }
        if (name == null && requireIdentity) {
            throw new JsonParseException("Theme is missing required localized text field: " + "name");
        }

View on GitHub (pinned to 24702dc5a0)