{"record":{"id":"ef63fbf0301b0e1a","repo":"apple/pkl","slug":"e-getmessage-ef63fb","errorCode":null,"errorMessage":"e.getMessage()","messagePattern":"e\\.getMessage\\(\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/util/pklbinary/AbstractPklBinaryDecoder.java","lineNumber":73,"sourceCode":"    this.collectionSizeLimit = collectionSizeLimit;\n  }\n\n  protected static class DecodeException extends RuntimeException {\n    public DecodeException(String msg, Object... args) {\n      super(new Formatter().format(msg, args).toString());\n    }\n  }\n\n  protected final Object decode() {\n    currPath = new ArrayDeque<>();\n    try {\n      try {\n        return doDecode();\n      } catch (MessageInsufficientBufferException e) {\n        throw new DecodeException(\"Unexpected EOF\", e);\n      }\n    } catch (IOException e) {\n      throw doIOFail(e);\n    } catch (MessagePackException | DecodeException e) {\n      var path = new ArrayList<String>(currPath.size());\n      for (var iter = currPath.descendingIterator(); iter.hasNext(); ) {\n        path.add(iter.next().toString());\n      }\n      Collections.reverse(path);\n      throw doFail(e, unpacker.getTotalReadBytes(), path);\n    }\n  }\n\n  private void assertLength(PklBinaryCode type, int len, int expected) {\n    if (len < expected) {\n      throw new DecodeException(\n          \"Expected %s structure to have at least %d slots, found %d\", type, expected + 1, len);\n    }\n  }\n\n  protected record DecodedObjectMember(PklBinaryCode type, Object key, Object value) {}","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/util/pklbinary/AbstractPklBinaryDecoder.java#L55-L91","documentation":"AbstractPklBinaryDecoder.decode wraps failures from the MessagePack-based Pkl binary decoding path. When a MessagePackException or DecodeException bubbles out of doDecode(), it is converted (via doFail) into a decoding failure whose message is built from e.getMessage(), annotated with the byte offset (unpacker.getTotalReadBytes()) and the current property path. It signals that the binary (pkl-binary/MensajePack) data does not conform to the expected Pkl object encoding at that offset/path.","triggerScenarios":"Calling the decoder (decode) on a byte buffer whose contents are not a valid Pkl binary encoding: wrong MessagePack type at a position the schema expects something else, malformed header bytes, or a DecodeException raised by a length/type assertion (e.g. assertLength) inside a container decoder.","commonSituations":"Consuming a stale or corrupted .pkl.bin artifact cached from an older Pkl version whose binary encoding changed; decoding a file that was truncated or corrupted in transit; pointing the loader at a file that is not Pkl binary format at all (e.g. plain MessagePack or text).","solutions":["Regenerate the binary module output with the current Pkl version so the encoding matches what the decoder expects.","Inspect the reported byte offset and property path to find which field is encoded incorrectly; re-export that value.","Verify the input really is Pkl binary format (not plain MessagePack or JSON) and is not truncated or corrupted (check size/checksum against the producer).","If you control the writer, fix the code that serializes the offending property so it emits the correct MessagePack type for the schema."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// before decoding: check format markers and size\nif (!isPklBinaryFormat(bytes) || bytes.length < MIN_HEADER_SIZE) {\n  throw new IllegalArgumentException(\"Not a valid Pkl binary payload\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  return decoder.decode(buffer);\n} catch (DecodeException e) {\n  // e carries byte offset + property path from doFail\n  throw new CorruptionException(\"Bad Pkl binary data at byte \" + e.getOffset() + \" path \" + e.getPath(), e);\n}","preventionTips":["Regenerate binary artifacts whenever the Pkl version or schema changes.","Checksum binary files at production time and verify before decoding.","Never decode files that are only presumed to be Pkl binary — verify producer/provenance first."],"tags":["messagepack","binary-decoding","deserialization"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}