HMCL-dev/HMCL · error · JsonParseException

Missing author name:

Error message

Missing author name: 

What it means

Thrown by ThemePackAuthor.fromJson when the author JSON object is present but has no "name" key. The object form of an author must carry a name (a string or LocalizedText); the library refuses to construct an author without one.

Solutions

  1. Add a "name" key to the author object: {"author": {"name": "Alice"}}.
  2. If you meant a simple author, replace the object with a plain string: {"author": "Alice"}.
  3. Rename misspelled keys (authorName, displayName) to "name".
  4. Validate the manifest JSON against the expected author schema before distributing the pack.

Example fix

// before
{"author": {"website": "https://example.com"}}
// after
{"author": {"name": "Alice", "website": "https://example.com"}}
Defensive patterns

Strategy: validation

Validate before calling

boolean hasAuthorName(JsonObject author) {
    return author != null && author.has("name") && !author.get("name").isJsonNull();
}

Try / catch

try { ThemePackAuthor a = ThemePackAuthor.fromJson(authorJson); } catch (JsonParseException e) { if (e.getMessage().startsWith("Missing author name")) fixManifest(); throw e; }

Prevention

When it happens

Trigger: Deserializing an author object like {"author": {}} or {"author": {"contact":"x"}} — i.e. a JsonObject without a "name" member — through ThemePackAuthor.fromJson.

Common situations: Hand-written manifests where the author object only contains optional-looking fields, manifests migrated from other formats using different key names (e.g. "authorName"), or truncated/partial JSON edits.

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


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

Appendix: source

Thrown at HMCL/src/main/java/org/jackhuang/hmcl/theme/ThemePackAuthor.java:102

    public static @Nullable ThemePackAuthor fromJson(@Nullable JsonElement json) throws JsonParseException {
        if (json == null || json instanceof JsonNull)
            return null;

        if (json instanceof JsonPrimitive primitive && primitive.isString()) {
            try {
                return new ThemePackAuthor(LocalizedText.plain(primitive.getAsString()));
            } catch (IllegalArgumentException e) {
                throw new JsonParseException(e);
            }
        }

        if (!(json instanceof JsonObject jsonObject)) {
            throw new JsonParseException("Theme-pack author must be an object or a string");
        }

        JsonElement nameJson = jsonObject.get("name");
        if (nameJson == null) {
            throw new JsonParseException("Missing author name: " + json);
        }

        LocalizedText name = LocalizedText.fromJson(nameJson);
        if (name == null) {
            throw new JsonParseException("The author name is null");
        }

        try {
            return new ThemePackAuthor(name);
        } catch (IllegalArgumentException e) {
            throw new JsonParseException(e);
        }
    }

    /// Creates theme-pack author metadata.
    ///
    /// @param name the localized author display name
    public ThemePackAuthor {

View on GitHub (pinned to 24702dc5a0)