{"record":{"id":"ec87138a301c2ab0","repo":"apple/pkl","slug":"unexpected-blank-object-module-uri","errorCode":null,"errorMessage":"Unexpected blank object module URI","messagePattern":"Unexpected blank object module URI","errorType":"exception","errorClass":"DecodeException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/util/pklbinary/AbstractPklBinaryDecoder.java","lineNumber":205,"sourceCode":"\n  private void checkCollectionLength(int length, String collectionType) {\n    if (length <= collectionSizeLimit) return;\n    throw new DecodeException(\n        \"Unable to decode %s of length %d, exceeded maximum collection size of %d\",\n        collectionType, length, collectionSizeLimit);\n  }\n\n  private Object decodeObject(int len) throws IOException {\n    assertLength(PklBinaryCode.OBJECT, len, 3);\n    currPath.push(\"'object\");\n\n    var className = unpacker.unpackString();\n    if (className.isBlank()) {\n      throw new DecodeException(\"Unexpected blank object class name\");\n    }\n    var classModuleUriString = unpacker.unpackString();\n    if (classModuleUriString.isBlank()) {\n      throw new DecodeException(\"Unexpected blank object module URI\");\n    }\n    var classModuleUri = URI.create(classModuleUriString);\n\n    var result =\n        doDecodeObject(\n            className, classModuleUri, new ObjectDecodeIterator(unpacker.unpackArrayHeader()));\n    unpacker.skipValue(len - 4);\n    currPath.pop();\n    return result;\n  }\n\n  private Object decodeMap(int len) throws IOException {\n    assertLength(PklBinaryCode.MAP, len, 1);\n    currPath.push(\"'map\");\n    var result = doDecodeMap(new MapDecodeIterator(unpacker.unpackMapHeader(), \"map\"));\n    unpacker.skipValue(len - 2);\n    currPath.pop();\n    return result;","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/util/pklbinary/AbstractPklBinaryDecoder.java#L187-L223","documentation":"Thrown by decodeObject when the OBJECT entry's module URI string (the URI of the module declaring the object's class) is empty or whitespace-only. The decoder needs a valid module URI to resolve the class, so a blank value is treated as malformed input.","triggerScenarios":"Decoding pkl-binary bytes where the second string field of an OBJECT entry is blank; payloads produced by an encoder that skipped the module-URI field; corruption shifting field boundaries.","commonSituations":"Hand-written encoders omitting the module URI; truncated files; decoding with a decoder version that expects a different OBJECT layout than the encoder used.","solutions":["Regenerate the payload with a matching Pkl encoder version","Verify the encoder always writes className, moduleUri, then members in order","Confirm the input file is a genuine Pkl binary and not truncated","Add producer-side validation that the module URI is non-blank"],"exampleFix":"// before\npacker.packString(className);\npacker.packString(\"\"); // module URI missing\n// after\npacker.packString(className);\npacker.packString(module.getUri().toString());","handlingStrategy":"validation","validationCode":"// producer-side guard\nif (moduleUri == null || moduleUri.isBlank()) throw new IllegalArgumentException(\"blank module URI\");","typeGuard":null,"tryCatchPattern":"try {\n  return decoder.decode(bytes);\n} catch (DecodeException e) {\n  if (e.getMessage().contains(\"blank object module URI\")) {\n    throw new MalformedPklBinaryException(e);\n  }\n  throw e;\n}","preventionTips":["Never omit the module URI field in OBJECT entries","Use the module's URI (module.getUri().toString()) directly rather than hand-built strings","Align encoder/decoder versions","Checksum payloads in transit"],"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"}