{"record":{"id":"a6037f805ab31335","repo":"HMCL-dev/HMCL","slug":"bad-build-number","errorCode":null,"errorMessage":"Bad Build-Number","messagePattern":"Bad Build-Number","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/auth/authlibinjector/AuthlibInjectorArtifactInfo.java","lineNumber":49,"sourceCode":"        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\n    public @NotNull String toString() {\n        return \"authlib-injector [buildNumber=\" + buildNumber + \", version=\" + version + \"]\";\n    }\n}\n","sourceCodeStart":31,"sourceCodeEnd":60,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/authlibinjector/AuthlibInjectorArtifactInfo.java#L31-L60","documentation":"AuthlibInjectorArtifactInfo.from parses the jar manifest's Build-Number attribute as an integer; a non-numeric value throws IOException \"Bad Build-Number\" wrapping the NumberFormatException, and a missing attribute throws \"Missing Build-Number\". This validates that the artifact is a properly built authlib-injector release.","triggerScenarios":"Reading a jar whose manifest Build-Number attribute is absent or non-numeric (e.g. \"abc\", empty, or locally rebuilt without the build plugin).","commonSituations":"Building authlib-injector from source without release tooling; corrupted manifest in a re-zipped jar; third-party or tampered downloads.","solutions":["Use an official authlib-injector release jar with a valid Build-Number","Re-download the artifact if the manifest was corrupted or stripped","When building locally, run the release build so Build-Number is populated"],"exampleFix":"// before\n// manifest Build-Number: 'dev'\nAuthlibInjectorArtifactInfo.from(jar); // throws Bad Build-Number\n// after\n// download official release, e.g. authlib-injector-1.2.5.jar\nAuthlibInjectorArtifactInfo.from(Path.of(\"authlib-injector-1.2.5.jar\"));","handlingStrategy":"try-catch","validationCode":"try (JarFile jf = new JarFile(jar.toFile())) {\n    String bn = jf.getManifest().getMainAttributes().getValue(\"Build-Number\");\n    if (bn == null || !bn.matches(\"\\\\d+\")) {\n        throw new IOException(\"Jar has invalid Build-Number: \" + bn);\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    AuthlibInjectorArtifactInfo info = AuthlibInjectorArtifactInfo.from(path);\n} catch (IOException e) {\n    log.error(\"Invalid artifact build metadata: {}\", e.getMessage());\n    // re-download official release\n}","preventionTips":["Use official release jars which always carry Build-Number","Validate manifest attributes before loading artifacts","Avoid locally rebuilt jars for production use"],"tags":["minecraft","authlib-injector","jar","manifest","parsing"],"backgroundTag":"invalid-argument-format","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"}