{"record":{"id":"b77c59d917e76377","repo":"HMCL-dev/HMCL","slug":"theme-pack-resource-name-is-blank","errorCode":null,"errorMessage":"Theme-pack resource name is blank","messagePattern":"Theme-pack resource name is blank","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"HMCL/src/main/java/org/jackhuang/hmcl/theme/ThemePackResource.java","lineNumber":76,"sourceCode":"    /// @param name the stable resource name\n    @NotNullByDefault\n    record File(Path path, String name) implements ThemePackResource {\n        /// Creates a file-backed theme-pack resource named after its file name.\n        ///\n        /// @param path the resource file path\n        public File(Path path) {\n            this(path, Objects.requireNonNull(path).getFileName().toString());\n        }\n\n        /// Creates a file-backed theme-pack resource.\n        ///\n        /// @param path the resource file path\n        /// @param name the stable resource name\n        public File {\n            path = Objects.requireNonNull(path).toAbsolutePath().normalize();\n            name = Objects.requireNonNull(name).trim();\n            if (name.isEmpty()) {\n                throw new IllegalArgumentException(\"Theme-pack resource name is blank\");\n            }\n        }\n\n        /// Opens the file.\n        @Override\n        public InputStream openStream() throws IOException {\n            return Files.newInputStream(path);\n        }\n\n        /// Returns the backing file.\n        @Override\n        public Path file() {\n            return path;\n        }\n    }\n\n    /// A resource stored as an entry inside a zip theme-pack file.\n    ///","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCL/src/main/java/org/jackhuang/hmcl/theme/ThemePackResource.java#L58-L94","documentation":"The ThemePackResource.File compact constructor normalizes the path and trims the name; if the trimmed resource name is empty it throws IllegalArgumentException \"Theme-pack resource name is blank\". Every packaged resource needs a stable, non-empty name for lookup within the pack.","triggerScenarios":"Constructing new ThemePackResource.File(path, name) with name = \"\" or whitespace-only; computing the name from a filename that ends up empty after trim.","commonSituations":"Iterating zip entries and passing an empty derived key; a renaming script that blanked resource names; passing Path.getFileName() results from a root path.","solutions":["Pass a meaningful non-empty name to the File record constructor.","If the name is derived from a path, use the file name component and verify it is non-blank before constructing.","Guard the call site with a check that skips or renames blank-named entries."],"exampleFix":"// before\nnew ThemePackResource.File(path, \"\")\n// after\nnew ThemePackResource.File(path, \"background.png\")","handlingStrategy":"validation","validationCode":"if (name == null || name.trim().isEmpty()) throw new IllegalArgumentException(\"resource name required\");","typeGuard":null,"tryCatchPattern":"try { resource = new ThemePackResource.File(path, name); } catch (IllegalArgumentException e) { skipEntry(path); }","preventionTips":["Derive names from Path.getFileName() and assert non-empty","Skip zip directory entries before constructing resources","Sanitize generated names with trim() plus a fallback"],"tags":["theme-pack","resource","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"}