{"record":{"id":"89d1e3a39b9662a7","repo":"HMCL-dev/HMCL","slug":"the-author-name-is-null","errorCode":null,"errorMessage":"The author name is null","messagePattern":"The author name is null","errorType":"validation","errorClass":"JsonParseException","httpStatus":null,"severity":"error","filePath":"HMCL/src/main/java/org/jackhuang/hmcl/theme/ThemePackAuthor.java","lineNumber":107,"sourceCode":"            try {\n                return new ThemePackAuthor(LocalizedText.plain(primitive.getAsString()));\n            } catch (IllegalArgumentException e) {\n                throw new JsonParseException(e);\n            }\n        }\n\n        if (!(json instanceof JsonObject jsonObject)) {\n            throw new JsonParseException(\"Theme-pack author must be an object or a string\");\n        }\n\n        JsonElement nameJson = jsonObject.get(\"name\");\n        if (nameJson == null) {\n            throw new JsonParseException(\"Missing author name: \" + json);\n        }\n\n        LocalizedText name = LocalizedText.fromJson(nameJson);\n        if (name == null) {\n            throw new JsonParseException(\"The author name is null\");\n        }\n\n        try {\n            return new ThemePackAuthor(name);\n        } catch (IllegalArgumentException e) {\n            throw new JsonParseException(e);\n        }\n    }\n\n    /// Creates theme-pack author metadata.\n    ///\n    /// @param name the localized author display name\n    public ThemePackAuthor {\n        if (name.mayBeEmpty()) {\n            throw new IllegalArgumentException(\"The author name cannot be empty\");\n        }\n    }\n","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCL/src/main/java/org/jackhuang/hmcl/theme/ThemePackAuthor.java#L89-L125","documentation":"Thrown by ThemePackAuthor.fromJson when LocalizedText.fromJson returns null for the \"name\" element — i.e. the name key exists but its content is empty or not decodable into a LocalizedText. The library treats a null decoded name as invalid rather than creating an author with no display name.","triggerScenarios":"Author object with a null or empty-structure name, e.g. {\"author\": {\"name\": null}} or {\"author\": {\"name\": {}}}, when ThemePackAuthor.fromJson decodes it.","commonSituations":"Templates that leave \"name\": null as a placeholder, programmatic manifest generation that skips filling the localized name, or JSON round-tripping that dropped the name value.","solutions":["Set a concrete name value: {\"author\": {\"name\": \"Alice\"}}.","If using the localized form, supply at least one locale entry, e.g. {\"name\": {\"en\": \"Alice\"}}.","Remove the \"name\": null placeholder before packaging.","Check LocalizedText.fromJson's accepted shapes and conform the name element to them."],"exampleFix":"// before\n{\"author\": {\"name\": null}}\n// after\n{\"author\": {\"name\": \"Alice\"}}","handlingStrategy":"validation","validationCode":"boolean decodableName(JsonElement nameJson) {\n    if (nameJson == null || nameJson.isJsonNull()) return false;\n    if (nameJson.isJsonPrimitive()) return nameJson.getAsJsonPrimitive().isString() && !nameJson.getAsString().isBlank();\n    return nameJson.isJsonObject();\n}","typeGuard":null,"tryCatchPattern":"try { ThemePackAuthor a = ThemePackAuthor.fromJson(json); } catch (JsonParseException e) { if (\"The author name is null\".equals(e.getMessage())) supplyDefaultName(); throw e; }","preventionTips":["Never leave \"name\": null placeholders in shipped manifests","Provide at least one locale entry for localized names","Round-trip test manifests through the loader before release"],"tags":["json","theme-pack","localized-text","null-value"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"24702dc5a0214034f4c27166d5fd30cad08cec19","analyzedAt":"2026-09-10T12:36:46.680Z","contentChangedAt":"2026-09-10T12:36:46.680Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}