{"record":{"id":"130dcb0f03c49fc0","repo":"apple/pkl","slug":"unrecognized-member-code-s","errorCode":null,"errorMessage":"Unrecognized member code %s","messagePattern":"Unrecognized member code (.+?)","errorType":"exception","errorClass":"DecodeException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/util/pklbinary/AbstractPklBinaryDecoder.java","lineNumber":454,"sourceCode":"      }\n      DecodedObjectMember member;\n      switch (memberCode) {\n        case PROPERTY -> {\n          var propertyName = unpacker.unpackString();\n          currPath.push(propertyName);\n          member = new DecodedObjectMember(memberCode, propertyName, doDecode());\n        }\n        case ENTRY -> {\n          var entryKey = doDecode();\n          currPath.push(entryKey);\n          member = new DecodedObjectMember(memberCode, entryKey, doDecode());\n        }\n        case ELEMENT -> {\n          var elementIndex = unpacker.unpackLong();\n          currPath.push(elementIndex);\n          member = new DecodedObjectMember(memberCode, elementIndex, doDecode());\n        }\n        default -> throw new DecodeException(\"Unrecognized member code %s\", memberCode);\n      }\n      currPath.pop();\n      return member;\n    }\n  }\n\n  protected class CollectionDecodeIterator extends DecodeIterator<Object> {\n    CollectionDecodeIterator(int size, String collectionType) {\n      super(size);\n      checkCollectionLength(size, collectionType);\n    }\n\n    @Override\n    Object getNext() throws IOException {\n      return doDecode();\n    }\n  }\n","sourceCodeStart":436,"sourceCodeEnd":472,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/util/pklbinary/AbstractPklBinaryDecoder.java#L436-L472","documentation":"Defensive branch in AbstractPklBinaryDecoder.getNext: after PklBinaryCode.fromInt() returned a non-null code, the switch over PROPERTY/ELEMENT hit the default case, meaning the code value is a valid PklBinaryCode but not one handled for object members. This indicates an internal encoder/decoder mismatch rather than corrupt data.","triggerScenarios":"Decoding a pkl binary object member whose PklBinaryCode resolves to a code that is not PROPERTY or ELEMENT (e.g. a member-kind code valid elsewhere in the format but not inside an object member), typically from a format-version mismatch or hand-crafted data.","commonSituations":"Producers written against a different revision of the pkl-binary spec; tests or fuzzers generating member codes that exist in the enum but are not legal in member position.","solutions":["Regenerate the payload with a producer matching the decoder's Pkl version","Check the emitted member code against the codes legal for object members (PROPERTY, ELEMENT)","If you control the encoder, ensure only PROPERTY/ELEMENT codes are written for object members","Report a bug to the encoder/decoder maintainers if versions match"],"exampleFix":"// before\nvar code = PklBinaryCode.fromInt(raw);\nwriteMember(code, value); // may write MAP entries in member position\n// after\nif (code != PklBinaryCode.PROPERTY && code != PklBinaryCode.ELEMENT) {\n  throw new IllegalArgumentException(\"illegal object member code: \" + code);\n}\nwriteMember(code, value);","handlingStrategy":"try-catch","validationCode":"int raw = /* member code byte */;\nif (raw != PklBinaryCode.PROPERTY_INT && raw != PklBinaryCode.ELEMENT_INT) throw new IllegalStateException(\"illegal member code \" + raw);\n","typeGuard":"boolean isMemberCode(PklBinaryCode c) { return c == PklBinaryCode.PROPERTY || c == PklBinaryCode.ELEMENT; }\n","tryCatchPattern":"try { member = decoder.getNext(); } catch (DecodeException e) { throw new UnsupportedPklBinaryVersionException(e); }\n","preventionTips":["Keep encoder and decoder Pkl versions in sync","Restrict encoders to PROPERTY/ELEMENT codes in member position","Fuzz-test encoders against the decoder","Pin the pkl-binary spec revision per artifact"],"tags":["pkl","binary-decoding","serialization"],"backgroundTag":"unsupported-enum-value","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"}