{"record":{"id":"bf41f801a83addf6","repo":"HMCL-dev/HMCL","slug":"manifest-is-null","errorCode":null,"errorMessage":"Manifest is null","messagePattern":"Manifest is null","errorType":"validation","errorClass":"JsonParseException","httpStatus":null,"severity":"error","filePath":"HMCL/src/main/java/org/jackhuang/hmcl/theme/ThemePackManager.java","lineNumber":380,"sourceCode":"    /// Loads and parses a theme-pack file or unpacked theme-pack directory.\n    ///\n    /// @param file the theme-pack file or directory\n    /// @return the loaded theme pack\n    /// @throws IOException if the file cannot be read or the manifest is invalid\n    public static LoadedThemePack load(Path file) throws IOException {\n        Objects.requireNonNull(file);\n\n        Path normalizedFile = file.toAbsolutePath().normalize();\n        try {\n            if (Files.isDirectory(normalizedFile)) {\n                Path manifestFile = normalizedFile.resolve(ThemePackExporter.MANIFEST_ENTRY);\n                if (!Files.isRegularFile(manifestFile)) {\n                    throw new IOException(\"Theme pack directory does not contain \" + ThemePackExporter.MANIFEST_ENTRY);\n                }\n\n                ThemePackManifest manifest = JsonUtils.fromJsonFile(manifestFile, ThemePackManifest.class);\n                if (manifest == null) {\n                    throw new JsonParseException(\"Manifest is null\");\n                }\n                return new LoadedThemePack(normalizedFile, manifest);\n            }\n\n            try (var reader = new ZipArchiveReader(normalizedFile)) {\n                var manifestEntry = reader.getEntry(ThemePackExporter.MANIFEST_ENTRY);\n                if (manifestEntry == null || manifestEntry.isDirectory()) {\n                    throw new IOException(\"Theme pack does not contain \" + ThemePackExporter.MANIFEST_ENTRY);\n                }\n\n                ThemePackManifest manifest;\n                try (var inputStream = reader.getInputStream(manifestEntry)) {\n                    manifest = JsonUtils.fromNonNullJsonFully(inputStream, ThemePackManifest.class);\n                }\n                return new LoadedThemePack(normalizedFile, manifest);\n            }\n        } catch (JsonParseException | IllegalArgumentException e) {\n            throw new IOException(\"Invalid theme-pack manifest\", e);","sourceCodeStart":362,"sourceCodeEnd":398,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCL/src/main/java/org/jackhuang/hmcl/theme/ThemePackManager.java#L362-L398","documentation":"Thrown by ThemePackManager.load when JsonUtils.fromJsonFile returns null while deserializing the theme pack manifest. Although the manifest file exists, its parsed result was null, which the loader treats as an unrecoverable parse failure rather than silently returning no pack.","triggerScenarios":"Loading a directory theme pack whose theme.json parses to null — e.g. a file containing only whitespace/null — via JsonUtils.fromJsonFile(manifestFile, ThemePackManifest.class).","commonSituations":"theme.json accidentally saved as empty or containing the literal text null, editors that truncated the file during a crash, or generation scripts writing a null placeholder.","solutions":["Open theme.json and restore valid manifest JSON (at minimum the required manifest fields).","Re-export the theme pack to regenerate a correct manifest.","Check the file is non-empty and does not literally contain \"null\".","Validate the JSON syntax with a linter before retrying the load."],"exampleFix":"// before (theme.json)\nnull\n// after (theme.json)\n{\"name\": \"My Theme\", \"author\": \"Alice\"}","handlingStrategy":"validation","validationCode":"Path manifest = dir.resolve(\"theme.json\");\nString text = Files.readString(manifest);\nif (text.isBlank() || text.strip().equals(\"null\")) throw new IllegalStateException(\"Manifest is empty/null\");","typeGuard":null,"tryCatchPattern":"try { manager.load(path); } catch (JsonParseException e) { if (\"Manifest is null\".equals(e.getMessage())) regenerateManifest(); throw e; }","preventionTips":["Never write empty or null placeholder manifests","Validate theme.json parses as a non-null object before loading","Use atomic file writes to avoid truncated manifests after crashes"],"tags":["json","theme-pack","manifest","parse"],"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-15T23:17:13.987Z"}