{"record":{"id":"6a58a694eb43ea04","repo":"apple/pkl","slug":"missingmessageparameter","errorCode":"missingMessageParameter","errorMessage":"missingMessageParameter","messagePattern":"missingMessageParameter","errorType":"error_code","errorClass":"DecodeException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/messaging/AbstractMessagePackDecoder.java","lineNumber":96,"sourceCode":"      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\n  protected static String unpackString(Map<Value, Value> map, String key) throws DecodeException {\n    return get(map, key).asStringValue().asString();\n  }\n\n  protected static @Nullable String unpackStringOrNull(Map<Value, Value> map, String key) {\n    var value = getNullable(map, key);\n    if (value == null) {\n      return null;\n    }\n    return value.asStringValue().asString();\n  }\n\n  protected static <T> @Nullable T unpackStringOrNull(\n      Map<Value, Value> map, String key, Function<String, T> mapper) {","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/messaging/AbstractMessagePackDecoder.java#L78-L114","documentation":"A required parameter key is absent from a decoded message body map. The helper get(map, key) throws DecodeException with code missingMessageParameter naming the missing key; helpers unpackString/unpackBoolean/unpackInt/unpackLong all route through it.","triggerScenarios":"Decoding a message whose body map lacks a mandatory field (e.g. no 'message' or 'uri' key) that a unpackXxx helper requests.","commonSituations":"Partial encoder implementations, schema drift between peers, hand-written or trimmed msgpack payloads missing fields.","solutions":["Ensure the encoder writes every required field for the message type","Compare the decoded map keys against the schema and add the missing field on the producer side","Use getNullable for genuinely optional fields instead of get","Validate incoming maps against the message schema before decoding"],"exampleFix":"// before: assumes optional key is present\nvar msg = unpackString(map, \"message\");\n// after: handle absence explicitly\nvar msgOrNull = getNullable(map, \"message\") == null ? \"\" : unpackString(map, \"message\");","handlingStrategy":"validation","validationCode":"boolean hasKey = map.containsKey(new ImmutableStringValueImpl(\"message\"));","typeGuard":"static boolean hasField(Map<Value,Value> map, String key) { return map.containsKey(new ImmutableStringValueImpl(key)); }","tryCatchPattern":"try { var msg = unpackString(map, \"message\"); } catch (DecodeException e) { if (String.valueOf(e.getMessage()).contains(\"missingMessageParameter\")) { /* supply default or reject producer payload */ } throw e; }","preventionTips":["Use getNullable for optional fields","Write schema tests for encoder output","Validate producer payloads before decode"],"tags":["msgpack","decoding","missing-field"],"backgroundTag":"missing-required-config-field","analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}