{"record":{"id":"88e59e78ee84d2cb","repo":"HMCL-dev/HMCL","slug":"theme-pack-authors-must-be-an-array","errorCode":null,"errorMessage":"Theme-pack authors must be an array","messagePattern":"Theme-pack authors must be an array","errorType":"validation","errorClass":"JsonParseException","httpStatus":null,"severity":"error","filePath":"HMCL/src/main/java/org/jackhuang/hmcl/theme/ThemePackAuthor.java","lineNumber":50,"sourceCode":"\nimport static org.jackhuang.hmcl.util.logging.Logger.LOG;\n\n/// Author metadata declared by a theme pack.\n///\n/// @param name the localized author display name\n@NotNullByDefault\n@JsonSerializable\n@JsonAdapter(ThemePackAuthor.Adapter.class)\npublic record ThemePackAuthor(LocalizedText name) {\n\n    /// Parses author metadata from a JSON array.\n    static @Unmodifiable List<ThemePackAuthor> parseAuthors(@Nullable JsonElement element) throws JsonParseException {\n        if (element == null || element.isJsonNull()) {\n            return List.of();\n        }\n\n        if (!(element instanceof JsonArray jsonArray)) {\n            throw new JsonParseException(\"Theme-pack authors must be an array\");\n        }\n\n        ArrayList<ThemePackAuthor> authors = new ArrayList<>(jsonArray.size());\n        int index = 0;\n        for (JsonElement authorJson : jsonArray) {\n            try {\n                ThemePackAuthor author = fromJson(authorJson);\n                if (author != null) {\n                    authors.add(author);\n                }\n            } catch (JsonParseException | IllegalArgumentException e) {\n                LOG.warning(\"Ignored invalid theme-pack author at authors[\" + index + \"]: \" + authorJson, e);\n            }\n            index++;\n        }\n\n        return List.copyOf(authors);\n    }","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCL/src/main/java/org/jackhuang/hmcl/theme/ThemePackAuthor.java#L32-L68","documentation":"parseAuthors parses the theme pack 'authors' field. A null element is treated as no authors, but if the element is present and is not a JSON array, JsonParseException(\"Theme-pack authors must be an array\") is thrown. Authors are always a list in the schema.","triggerScenarios":"Calling parseAuthors (via theme pack parsing) where the 'authors' field is a string (e.g. \"authors\": \"Alice\"), an object, or a number instead of an array.","commonSituations":"Theme pack authors write a single author as a plain string instead of [\"Alice\"], or an older/other tool emitted a different shape.","solutions":["Change the authors field to a JSON array, e.g. \"authors\": [\"Alice\"]","If a single author, wrap it: \"authors\": [\"value\"]","Validate the theme pack JSON against the schema before loading"],"exampleFix":"// before\n\"authors\": \"Alice\"\n// after\n\"authors\": [\"Alice\"]","handlingStrategy":"validation","validationCode":"static boolean isValidAuthors(JsonElement e) {\n    return e == null || e.isJsonNull() || e.isJsonArray();\n}","typeGuard":"static boolean isJsonArrayOrNull(JsonElement e) {\n    return e == null || e instanceof JsonArray;\n}","tryCatchPattern":"try {\n    List<ThemePackAuthor> authors = parseAuthors(el.get(\"authors\"));\n} catch (JsonParseException e) {\n    log.warn(\"Ignoring invalid authors field: \" + e.getMessage());\n}","preventionTips":["Always write authors as a JSON array, even for one author","Validate theme pack JSON against the schema before loading","Check the theme pack format version matches the loader"],"tags":["json","theme-pack","schema"],"backgroundTag":"type-mismatch","analyzedSha":"24702dc5a0214034f4c27166d5fd30cad08cec19","analyzedAt":"2026-09-10T12:36:46.680Z","contentChangedAt":"2026-09-10T12:36:46.680Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}