{"record":{"id":"dc5d5c66108ba4b8","repo":"HMCL-dev/HMCL","slug":"bad-implementation-title","errorCode":null,"errorMessage":"Bad Implementation-Title","messagePattern":"Bad Implementation-Title","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/auth/authlibinjector/AuthlibInjectorArtifactInfo.java","lineNumber":37,"sourceCode":"\nimport org.jetbrains.annotations.NotNull;\n\nimport java.io.IOException;\nimport java.nio.file.Path;\nimport java.util.Optional;\nimport java.util.jar.Attributes;\nimport java.util.jar.JarFile;\n\npublic record AuthlibInjectorArtifactInfo(int buildNumber, String version, Path location) {\n\n    public static AuthlibInjectorArtifactInfo from(Path location) throws IOException {\n        try (JarFile jarFile = new JarFile(location.toFile())) {\n            Attributes attributes = jarFile.getManifest().getMainAttributes();\n\n            String title = Optional.ofNullable(attributes.getValue(\"Implementation-Title\"))\n                    .orElseThrow(() -> new IOException(\"Missing Implementation-Title\"));\n            if (!\"authlib-injector\".equals(title)) {\n                throw new IOException(\"Bad Implementation-Title\");\n            }\n\n            String version = Optional.ofNullable(attributes.getValue(\"Implementation-Version\"))\n                    .orElseThrow(() -> new IOException(\"Missing Implementation-Version\"));\n\n            int buildNumber;\n            try {\n                buildNumber = Optional.ofNullable(attributes.getValue(\"Build-Number\"))\n                        .map(Integer::parseInt)\n                        .orElseThrow(() -> new IOException(\"Missing Build-Number\"));\n            } catch (NumberFormatException e) {\n                throw new IOException(\"Bad Build-Number\", e);\n            }\n            return new AuthlibInjectorArtifactInfo(buildNumber, version, location.toAbsolutePath());\n        }\n    }\n\n    @Override","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/authlibinjector/AuthlibInjectorArtifactInfo.java#L19-L55","documentation":"AuthlibInjectorArtifactInfo.from inspects the jar manifest and requires Implementation-Title to equal \"authlib-injector\"; any other title throws IOException \"Bad Implementation-Title\". This verifies that the located artifact really is an authlib-injector build, not an arbitrary jar.","triggerScenarios":"Calling AuthlibInjectorArtifactInfo.from(Path) on a jar whose manifest Implementation-Title differs from \"authlib-injector\" (or whose jar/manifest cannot be read as expected).","commonSituations":"Pointing the downloader/library path at a renamed or unrelated jar; a corrupted or rebuilt artifact with wrong manifest attributes; tampered mirror downloads.","solutions":["Download the artifact from the official authlib-injector release so the manifest is correct","Verify the jar's manifest Implementation-Title before passing it to from()","Re-download the file if it was renamed, rebuilt, or corrupted"],"exampleFix":"// before\nPath jar = Path.of(\"some-random.jar\");\nAuthlibInjectorArtifactInfo info = AuthlibInjectorArtifactInfo.from(jar);\n// after\n// verify manifest before calling\ntry (JarFile jf = new JarFile(jar.toFile())) {\n    String title = jf.getManifest().getMainAttributes().getValue(\"Implementation-Title\");\n    if (\"authlib-injector\".equals(title)) {\n        AuthlibInjectorArtifactInfo info = AuthlibInjectorArtifactInfo.from(jar);\n    }\n}","handlingStrategy":"try-catch","validationCode":"try (JarFile jf = new JarFile(jar.toFile())) {\n    String title = jf.getManifest().getMainAttributes().getValue(\"Implementation-Title\");\n    if (!\"authlib-injector\".equals(title)) {\n        throw new IOException(\"Not an authlib-injector artifact: \" + title);\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    AuthlibInjectorArtifactInfo info = AuthlibInjectorArtifactInfo.from(path);\n} catch (IOException e) {\n    log.error(\"Invalid authlib-injector artifact at {}: {}\", path, e.getMessage());\n    // trigger re-download\n}","preventionTips":["Download artifacts only from official sources","Verify jar checksums after download","Never rename/repack authlib-injector jars"],"tags":["minecraft","authlib-injector","jar","manifest","validation"],"backgroundTag":"invalid-argument-value","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"}