{"record":{"id":"4aadd53c3131cd5a","repo":"apple/pkl","slug":"unhandledmessagecode","errorCode":"unhandledMessageCode","errorMessage":"unhandledMessageCode","messagePattern":"unhandledMessageCode","errorType":"error_code","errorClass":"DecodeException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/messaging/AbstractMessagePackDecoder.java","lineNumber":82,"sourceCode":"      throw new DecodeException(ErrorMessages.create(\"malformedMessageHeaderException\"), e);\n    }\n\n    Type msgType;\n    try {\n      msgType = Type.fromInt(code);\n    } catch (IllegalArgumentException e) {\n      throw new DecodeException(\n          ErrorMessages.create(\"malformedMessageHeaderUnrecognizedCode\", Integer.toHexString(code)),\n          e);\n    }\n\n    try {\n      var map = unpacker.unpackValue().asMapValue().map();\n      var decoded = decodeMessage(msgType, map);\n      if (decoded != null) {\n        return decoded;\n      }\n      throw new DecodeException(\n          ErrorMessages.create(\"unhandledMessageCode\", Integer.toHexString(code)));\n    } catch (MessageTypeException | URISyntaxException e) {\n      throw new DecodeException(ErrorMessages.create(\"malformedMessageBody\", code), e);\n    }\n  }\n\n  protected static @Nullable Value getNullable(Map<Value, Value> map, String key) {\n    return map.get(new ImmutableStringValueImpl(key));\n  }\n\n  protected static Value get(Map<Value, Value> map, String key) throws DecodeException {\n    var value = map.get(new ImmutableStringValueImpl(key));\n    if (value == null) {\n      throw new DecodeException(ErrorMessages.create(\"missingMessageParameter\", key));\n    }\n    return value;\n  }\n","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/messaging/AbstractMessagePackDecoder.java#L64-L100","documentation":"decodeMessage returned null for a recognized message type, meaning the concrete decoder subclass does not implement handling for that message code. The decoder treats this as a protocol gap and throws unhandledMessageCode with the hex code.","triggerScenarios":"A Type is recognized by Type.fromInt but decodeMessage(msgType, map) has no case for it and returns null.","commonSituations":"Custom or partial decoder implementations missing handlers for some message types (e.g. LogMessage, WarningMessage); base-class users decoding streams that include control messages they didn't implement.","solutions":["Implement a decodeMessage branch for the reported message type","Override decodeMessage to skip (return a no-op message) instead of null for ignorable types","Filter the stream upstream to drop unhandled message codes","Update to a decoder version that covers all message types"],"exampleFix":"// before\ncase CAN_EVALUATE -> null; // falls through to unhandledMessageCode\n// after\ncase CAN_EVALUATE -> decodeCanEvaluate(map); // implement or explicitly skip","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { return decoder.decode(unpacker); } catch (DecodeException e) { if (String.valueOf(e.getMessage()).contains(\"unhandledMessageCode\")) { return MessageSkip.INSTANCE; /* or rethrow */ } throw e; }","preventionTips":["Implement all message types in decodeMessage","Return explicit skip messages instead of null","Cover new message types when upgrading"],"tags":["msgpack","decoding","protocol"],"backgroundTag":"unsupported-operation","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"}