{"record":{"id":"d9523c6f0642ca6f","repo":"HMCL-dev/HMCL","slug":"fabric-metadata-is-invalid","errorCode":null,"errorMessage":"Fabric metadata is invalid","messagePattern":"Fabric metadata is invalid","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/download/fabric/FabricInstallTask.java","lineNumber":92,"sourceCode":"    public Collection<Task<?>> getDependents() {\n        return Collections.singleton(launchMetaTask);\n    }\n\n    @Override\n    public Collection<Task<?>> getDependencies() {\n        return dependencies;\n    }\n\n    @Override\n    public boolean isRelyingOnDependencies() {\n        return false;\n    }\n\n    @Override\n    public void execute() throws IOException {\n        FabricInfo fabricInfo = JsonUtils.GSON.fromJson(launchMetaTask.getResult(), FabricInfo.class);\n        if (fabricInfo == null)\n            throw new IOException(\"Fabric metadata is invalid\");\n\n        setResult(getPatch(fabricInfo, remote.getGameVersion(), remote.getSelfVersion()));\n\n        dependencies.add(new GameLibrariesTask(dependencyManager, manifest, true, getResult().getLibraries()));\n    }\n\n    private GameInstancePatch getPatch(FabricInfo fabricInfo, String gameVersion, String loaderVersion) {\n        JsonObject launcherMeta = fabricInfo.launcherMeta;\n        Arguments arguments = new Arguments();\n\n        String mainClass;\n        if (!launcherMeta.get(\"mainClass\").isJsonObject()) {\n            mainClass = launcherMeta.get(\"mainClass\").getAsString();\n        } else {\n            mainClass = launcherMeta.get(\"mainClass\").getAsJsonObject().get(\"client\").getAsString();\n        }\n\n        if (launcherMeta.has(\"launchwrapper\")) {","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/download/fabric/FabricInstallTask.java#L74-L110","documentation":"Thrown by FabricInstallTask.execute when Gson parses the Fabric launcher metadata but yields null, meaning the downloaded JSON is empty, malformed, or not deserializable into FabricInfo. The install cannot proceed without valid loader metadata.","triggerScenarios":"launchMetaTask.getResult() returns an empty string, invalid JSON, or JSON whose shape Gson cannot map to FabricInfo (GSON.fromJson returns null on empty input).","commonSituations":"Fabric meta API outage or HTML error page returned instead of JSON, wrong metadata URL, proxy/captive portal interference, or unsupported Fabric version endpoint.","solutions":["Check network connectivity / retry the download of Fabric metadata","Verify the Fabric meta URL and requested loader/game version are valid","Inspect the raw getResult() payload to see what was actually downloaded"],"exampleFix":"// before\nFabricInfo fabricInfo = JsonUtils.GSON.fromJson(launchMetaTask.getResult(), FabricInfo.class);\nif (fabricInfo == null) throw new IOException(\"Fabric metadata is invalid\");\n// after\nString raw = launchMetaTask.getResult();\nif (raw == null || raw.isBlank() || !raw.trim().startsWith(\"{\"))\n    throw new IOException(\"Fabric metadata download failed, got: \" + preview(raw));","handlingStrategy":"try-catch","validationCode":"String raw = launchMetaTask.getResult();\nif (raw == null || raw.isBlank() || !raw.stripLeading().startsWith(\"{\"))\n    throw new IOException(\"Fabric metadata is not valid JSON: \" + (raw == null ? \"null\" : raw.substring(0, Math.min(120, raw.length()))));","typeGuard":"static boolean looksLikeJson(String s) {\n    return s != null && !s.isBlank() && (s.stripLeading().startsWith(\"{\") || s.stripLeading().startsWith(\"[\"));\n}","tryCatchPattern":"try {\n    installTask.execute();\n} catch (IOException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"Fabric metadata\")) {\n        ui.showError(\"Could not read Fabric metadata; check network/mirror and retry\");\n    }\n}","preventionTips":["Verify connectivity to fabricmc.net meta endpoints before install","Pin supported Fabric loader/game versions","Log the raw payload on failure to distinguish outage vs schema change"],"tags":["java","fabric","json","download"],"backgroundTag":"invalid-json-response","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"}