{"record":{"id":"6bfe0d2109be8f14","repo":"apple/pkl","slug":"unexpected-blank-typealias-name","errorCode":null,"errorMessage":"Unexpected blank typealias name","messagePattern":"Unexpected blank typealias name","errorType":"exception","errorClass":"DecodeException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/util/pklbinary/AbstractPklBinaryDecoder.java","lineNumber":355,"sourceCode":"    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();\n    if (name.isBlank()) {\n      throw new DecodeException(\"Unexpected blank typealias name\");\n    }\n    var moduleUriString = unpacker.unpackString();\n    if (moduleUriString.isBlank()) {\n      throw new DecodeException(\"Unexpected blank typealias module URI\");\n    }\n    var moduleUri = URI.create(moduleUriString);\n\n    var result = doDecodeTypeAlias(name, moduleUri);\n    unpacker.skipValue(len - 3);\n    currPath.pop();\n    return result;\n  }\n\n  private Object decodeFunction(int len) throws IOException {\n    assertLength(PklBinaryCode.FUNCTION, len, 0);\n    currPath.push(\"'function\");\n    var result = doDecodeFunction();\n    unpacker.skipValue(len - 1);","sourceCodeStart":337,"sourceCodeEnd":373,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/util/pklbinary/AbstractPklBinaryDecoder.java#L337-L373","documentation":"Thrown by decodeTypeAlias when a TYPEALIAS entry's name string is empty or whitespace-only. Typealias references must be identified by name for the decoder to resolve them, so a blank name is treated as malformed binary input.","triggerScenarios":"Decoding pkl-binary bytes where a TYPEALIAS code encodes an empty name string; corrupted payloads; an encoder writing fields in the wrong order so the blank URI is read as the name.","commonSituations":"Hand-written encoders; version mismatch between producer and consumer on the TYPEALIAS entry layout; truncated input.","solutions":["Fix the encoder to emit the non-blank typealias name before the module URI","Regenerate the payload with the matching Pkl encoder","Confirm the input is a valid, complete Pkl binary file","Validate names at the producer before packing"],"exampleFix":"// before\npacker.packString(\"\");\npacker.packString(moduleUri);\n// after\npacker.packString(\"my.pkg.MyAlias\");\npacker.packString(moduleUri);","handlingStrategy":"validation","validationCode":"if (name == null || name.isBlank()) throw new IllegalArgumentException(\"blank typealias name\");","typeGuard":null,"tryCatchPattern":"try {\n  return decoder.decode(bytes);\n} catch (DecodeException e) {\n  if (e.getMessage().contains(\"blank typealias name\")) {\n    throw new MalformedPklBinaryException(e);\n  }\n  throw e;\n}","preventionTips":["Encode the non-blank typealias name first","Validate names at the producer","Align Pkl versions between encoder and decoder","Check for truncation 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"}