{"record":{"id":"bfa597a7d3d03b5c","repo":"apple/pkl","slug":"unexpected-blank-typealias-module-uri","errorCode":null,"errorMessage":"Unexpected blank typealias module URI","messagePattern":"Unexpected blank typealias module URI","errorType":"exception","errorClass":"DecodeException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/util/pklbinary/AbstractPklBinaryDecoder.java","lineNumber":359,"sourceCode":"    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);\n    currPath.pop();\n    return result;\n  }\n","sourceCodeStart":341,"sourceCodeEnd":377,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/util/pklbinary/AbstractPklBinaryDecoder.java#L341-L377","documentation":"Thrown by decodeTypeAlias when the TYPEALIAS entry's module URI string is blank. The decoder resolves the typealias via (name, moduleUri); a missing URI makes the reference unresolvable and the payload malformed.","triggerScenarios":"Decoding pkl-binary bytes where the second string of a TYPEALIAS entry is empty; an encoder skipping the module URI; corruption shifting field boundaries.","commonSituations":"Third-party encoders omitting the URI; truncated files; decoder/encoder layout mismatch across Pkl versions.","solutions":["Ensure the encoder writes the module URI after the name","Regenerate the payload with a matching Pkl version","Check payload integrity before decoding","Reject blank module URIs on the producer side"],"exampleFix":"// before\npacker.packString(name);\n// after\npacker.packString(name);\npacker.packString(module.getUri().toString());","handlingStrategy":"validation","validationCode":"if (moduleUri == null || moduleUri.isBlank()) throw new IllegalArgumentException(\"blank typealias module URI\");","typeGuard":null,"tryCatchPattern":"try {\n  return decoder.decode(bytes);\n} catch (DecodeException e) {\n  if (e.getMessage().contains(\"blank typealias module URI\")) {\n    throw new MalformedPklBinaryException(e);\n  }\n  throw e;\n}","preventionTips":["Always write the module URI as the second string of a TYPEALIAS entry","Use module.getUri().toString() rather than hand-built URIs","Keep versions matched","Validate payload integrity"],"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"}