{"record":{"id":"682ffbf157a1fcbc","repo":"apple/pkl","slug":"unexpected-msgpack-ext-value","errorCode":null,"errorMessage":"Unexpected msgpack ext value","messagePattern":"Unexpected msgpack ext value","errorType":"exception","errorClass":"DecodeException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/util/pklbinary/AbstractPklBinaryDecoder.java","lineNumber":152,"sourceCode":"      throw new DecodeException(\"Unexpected EOF\");\n    }\n\n    return switch (unpacker.getNextFormat().getValueType()) {\n      // primitives\n      case NIL -> {\n        unpacker.unpackNil();\n        yield doDecodeNull();\n      }\n      case STRING -> unpacker.unpackString();\n      case INTEGER -> unpacker.unpackLong();\n      case BOOLEAN -> unpacker.unpackBoolean();\n      case FLOAT -> unpacker.unpackDouble();\n      // non-primitive\n      case ARRAY -> decodeNonPrimitive();\n      // things we should never see outside a non-primitive\n      case BINARY -> throw new DecodeException(\"Unexpected msgpack bin value\");\n      case MAP -> throw new DecodeException(\"Unexpected msgpack map value\");\n      case EXTENSION -> throw new DecodeException(\"Unexpected msgpack ext value\");\n    };\n  }\n\n  private Object decodeNonPrimitive() throws IOException {\n    var len = unpacker.unpackArrayHeader();\n    if (len < 1) {\n      throw new DecodeException(\"Unexpected empty object array value\");\n    }\n\n    var codeInt = unpacker.unpackInt();\n    var code = PklBinaryCode.fromInt(codeInt);\n    if (code == null) {\n      throw new DecodeException(\"Unrecognized code 0x%x\", (byte) codeInt);\n    }\n\n    return switch (code) {\n      case OBJECT -> decodeObject(len);\n      case MAP -> decodeMap(len);","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/util/pklbinary/AbstractPklBinaryDecoder.java#L134-L170","documentation":"DecodeException thrown by doDecode() when a top-level msgpack value has type EXTENSION (ext format). The Pkl binary protocol never uses msgpack extension types, so encountering one means the input is not Pkl binary data (or is from a newer/foreign producer).","triggerScenarios":"Feeding msgpack containing ext values (e.g. timestamps or custom typed extensions from other serializers) into the Pkl binary decoder; version/protocol mismatch introducing ext types.","commonSituations":"Piping data serialized by msgpack-java with ext type registries (e.g. MessagePack timestamps) into Pkl tooling; protocol confusion between services.","solutions":["Regenerate the payload with Pkl's binary encoder, which never emits ext values","Remove/convert extension-typed fields before handing the stream to the Pkl decoder","Verify the byte stream actually belongs to Pkl binary output","Check producer and consumer protocol versions"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Producers must not emit msgpack ext values on the Pkl binary channel\n// convert ext-typed data (e.g. timestamps) to supported primitives before encoding","typeGuard":null,"tryCatchPattern":"try {\n  Object v = decoder.decode(bytes);\n} catch (DecodeException e) {\n  if (\"Unexpected msgpack ext value\".equals(e.getMessage())) {\n    // upstream used ext types (e.g. msgpack timestamps); re-encode without extensions\n  } else throw e;\n}","preventionTips":["Disable ext-type registries when serializing for Pkl consumers","Convert timestamps/custom types to strings or numbers first","Verify data provenance: only Pkl-encoded bytes should reach this decoder"],"tags":["msgpack","decoding","pkl-binary","malformed-input"],"backgroundTag":"invalid-msgpack-value","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"}