{"record":{"id":"4dd1cb1e57f9ed39","repo":"apple/pkl","slug":"unexpected-blank-class-name","errorCode":null,"errorMessage":"Unexpected blank class name","messagePattern":"Unexpected blank class name","errorType":"exception","errorClass":"DecodeException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/util/pklbinary/AbstractPklBinaryDecoder.java","lineNumber":335,"sourceCode":"    return result;\n  }\n\n  private Object decodeRegex(int len) throws IOException {\n    assertLength(PklBinaryCode.REGEX, len, 1);\n    currPath.push(\"'regex\");\n    var result = doDecodeRegex(Pattern.compile(unpacker.unpackString()));\n    unpacker.skipValue(len - 2);\n    currPath.pop();\n    return result;\n  }\n\n  private Object decodeClass(int len) throws IOException {\n    assertLength(PklBinaryCode.CLASS, len, 2);\n    currPath.push(\"'class\");\n\n    var name = unpacker.unpackString();\n    if (name.isBlank()) {\n      throw new DecodeException(\"Unexpected blank class name\");\n    }\n    var moduleUriString = unpacker.unpackString();\n    if (moduleUriString.isBlank()) {\n      throw new DecodeException(\"Unexpected blank class module URI\");\n    }\n    var moduleUri = URI.create(moduleUriString);\n\n    var result = doDecodeClass(name, moduleUri);\n    unpacker.skipValue(len - 3);\n    currPath.pop();\n    return result;\n  }\n\n  private Object decodeTypeAlias(int len) throws IOException {\n    assertLength(PklBinaryCode.TYPEALIAS, len, 2);\n    currPath.push(\"'typealias\");\n\n    var name = unpacker.unpackString();","sourceCodeStart":317,"sourceCodeEnd":353,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/util/pklbinary/AbstractPklBinaryDecoder.java#L317-L353","documentation":"Thrown by decodeClass when a CLASS entry's name string is empty or whitespace-only. A class reference in the Pkl binary format must carry the fully qualified class name so the decoder can resolve it; a blank name signals malformed input.","triggerScenarios":"Decoding pkl-binary bytes where a CLASS code encodes an empty name string; corruption shifting string boundaries; a buggy encoder writing fields out of order.","commonSituations":"Hand-crafted payloads; encoder/decoder version mismatch on the CLASS entry layout; truncated downloads being fed to the decoder.","solutions":["Fix the encoder to always emit the non-blank class name first","Regenerate the payload with the matching Pkl version","Verify the input is a complete, untruncated Pkl binary file","Add producer-side validation rejecting blank names before packing"],"exampleFix":"// before\npacker.packString(\"\");\npacker.packString(moduleUri);\n// after\npacker.packString(\"my.pkg.MyClass\");\npacker.packString(moduleUri);","handlingStrategy":"validation","validationCode":"if (name == null || name.isBlank()) throw new IllegalArgumentException(\"blank class name\");","typeGuard":null,"tryCatchPattern":"try {\n  return decoder.decode(bytes);\n} catch (DecodeException e) {\n  if (e.getMessage().contains(\"blank class name\")) {\n    throw new MalformedPklBinaryException(e);\n  }\n  throw e;\n}","preventionTips":["Encode name then moduleUri in CLASS entries, always in order","Guard for blank strings on the producer","Match encoder/decoder Pkl versions","Verify file integrity before decoding"],"tags":["pkl","binary-decoder","corrupt-payload"],"backgroundTag":"empty-required-field","analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}