{"record":{"id":"6daeec3a4865aa70","repo":"HMCL-dev/HMCL","slug":"the-author-name-cannot-be-empty","errorCode":null,"errorMessage":"The author name cannot be empty","messagePattern":"The author name cannot be empty","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"HMCL/src/main/java/org/jackhuang/hmcl/theme/ThemePackAuthor.java","lineNumber":122,"sourceCode":"\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\n    /// Returns the author display name in the current locale.\n    ///\n    /// @return the localized author display name\n    public String displayName() {\n        return name.getText(I18n.getLocale().getCandidateLocales());\n    }\n\n    /// Converts this author to its JSON representation.\n    ///\n    /// @return the JSON object representing this author\n    public JsonObject toJsonObject() {\n        JsonObject object = new JsonObject();\n        object.add(\"name\", name.toJsonElement());\n        return object;\n    }","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCL/src/main/java/org/jackhuang/hmcl/theme/ThemePackAuthor.java#L104-L140","documentation":"Thrown by the ThemePackAuthor compact constructor when the supplied LocalizedText name is empty (mayBeEmpty() is true). An author record with an empty display name is considered meaningless, so the constructor enforces non-emptiness as an invariant.","triggerScenarios":"Calling new ThemePackAuthor(LocalizedText.of(\"\")) or constructing via fromJson where the name decodes to an empty string, e.g. {\"author\": {\"name\": \"\"}}.","commonSituations":"Manifest editors that clear the name field but keep the key, scripts that default missing values to empty strings, or users who blanked the author name in a pack-creation UI.","solutions":["Provide a non-empty author name in the manifest: {\"author\": {\"name\": \"Alice\"}}.","In code, ensure the LocalizedText passed to the constructor has at least one non-empty value.","Fall back to a placeholder name (e.g. \"Unknown\") if the source metadata is empty."],"exampleFix":"// before\nnew ThemePackAuthor(LocalizedText.of(\"\"))\n// after\nnew ThemePackAuthor(LocalizedText.of(\"Alice\"))","handlingStrategy":"validation","validationCode":"boolean nonEmptyName(LocalizedText name) {\n    return name != null && !name.mayBeEmpty();\n}","typeGuard":null,"tryCatchPattern":"try { new ThemePackAuthor(name); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"cannot be empty\")) name = LocalizedText.of(\"Unknown\"); else throw e; }","preventionTips":["Default empty author names to a placeholder before constructing","Validate UI input so blank names cannot be saved into manifests","Trim names and reject blank strings early in your pipeline"],"tags":["theme-pack","validation","empty-value","constructor"],"backgroundTag":"empty-required-field","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"}