{"record":{"id":"dbdac2c6ce1a69f3","repo":"HMCL-dev/HMCL","slug":"artifact-name-is-malformed","errorCode":null,"errorMessage":"Artifact name is malformed","messagePattern":"Artifact name is malformed","errorType":"validation","errorClass":"JsonParseException","httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/game/Artifact.java","lineNumber":143,"sourceCode":"\n    @Override\n    public String toString() {\n        return descriptor;\n    }\n\n    public static final class Adapter extends TypeAdapter<@Nullable Artifact> {\n\n        @Override\n        public @Nullable Artifact read(JsonReader in) throws IOException {\n            if (in.peek() == JsonToken.NULL) {\n                in.nextNull();\n                return null;\n            }\n\n            try {\n                return fromDescriptor(in.nextString());\n            } catch (IllegalArgumentException e) {\n                throw new JsonParseException(e);\n            }\n        }\n\n        @Override\n        public void write(JsonWriter out, @Nullable Artifact value) throws IOException {\n            if (value == null) {\n                out.nullValue();\n            } else {\n                out.value(value.toString());\n            }\n        }\n    }\n}\n","sourceCodeStart":125,"sourceCodeEnd":157,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/game/Artifact.java#L125-L157","documentation":"Thrown (as a JsonParseException caused by IllegalArgumentException from Artifact.fromDescriptor) when the library deserializes a Maven-artifact-style coordinate string for a library/download entry and the string does not split into the expected groupId:artifactId:version[@classifier@ext] parts. HMCL uses this to parse 'libraries' entries in version JSON files, so a malformed coordinate means the version metadata itself is broken.","triggerScenarios":"Calling the Artifact Gson TypeAdapter's read() on JSON whose string value lacks the required colon-separated segments (e.g. 'my-lib' or 'a:b:' instead of 'net.foo:my-lib:1.0'), or manually constructing an artifact descriptor with wrong syntax via Artifact.fromDescriptor.","commonSituations":"Hand-edited or third-party version JSONs with truncated library names; corrupted download of the version json; copying a Gradle dependency notation with extras like 'net.foo:lib:1.0@jar ' trailing data the parser rejects; custom forks generating library lists programmatically.","solutions":["Open the version JSON (versions/<id>/<id>.json) and fix the malformed library 'name' string to the full groupId:artifactId:version[:classifier] format","Re-download the version JSON from its source (launcher metadata / Mojang) instead of hand-editing","If generating JSON yourself, validate each library name matches ^[^:]+:[^:]+:[^:]+(?:[^:]*)? before writing","Catch JsonParseException when parsing third-party version metadata and surface the offending library name to the user"],"exampleFix":"// before\n\"name\": \"org.lwjgl\"\n// after\n\"name\": \"org.lwjgl:lwjgl:3.3.1\"","handlingStrategy":"validation","validationCode":"static boolean isValidArtifactName(String name) {\n    return name != null && name.matches(\"[^:]+:[^:]+:[^:]+.*\");\n}\n// check each library entry before feeding it to the parser","typeGuard":"boolean validDescriptor = s != null && s.chars().filter(c -> c == ':').count() >= 2;","tryCatchPattern":"try {\n    Artifact a = artifactAdapter.parse(json);\n} catch (JsonParseException e) {\n    LOG.warning(\"Skipping malformed library descriptor: \" + e.getCause().getMessage());\n    continue;\n}","preventionTips":["Never hand-edit library 'name' fields in version JSONs","Validate library coordinates against the colon-separated pattern before writing version JSON","Re-download version metadata from its official source after corruption"],"tags":["json","parsing","minecraft-version-metadata"],"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"}