{"record":{"id":"07bfc06d6717291c","repo":"apple/pkl","slug":"unrecognized-object-code-s","errorCode":null,"errorMessage":"Unrecognized object code %s","messagePattern":"Unrecognized object code (.+?)","errorType":"exception","errorClass":"DecodeException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/util/pklbinary/AbstractPklBinaryDecoder.java","lineNumber":184,"sourceCode":"    }\n\n    return switch (code) {\n      case OBJECT -> decodeObject(len);\n      case MAP -> decodeMap(len);\n      case MAPPING -> decodeMapping(len);\n      case LIST -> decodeList(len);\n      case LISTING -> decodeListing(len);\n      case SET -> decodeSet(len);\n      case DURATION -> decodeDuration(len);\n      case DATASIZE -> decodeDataSize(len);\n      case PAIR -> decodePair(len);\n      case INTSEQ -> decodeIntSeq(len);\n      case REGEX -> decodeRegex(len);\n      case CLASS -> decodeClass(len);\n      case TYPEALIAS -> decodeTypeAlias(len);\n      case FUNCTION -> decodeFunction(len);\n      case BYTES -> decodeBytes(len);\n      default -> throw new DecodeException(\"Unrecognized object code %s\", code);\n    };\n  }\n\n  private void checkCollectionLength(int length, String collectionType) {\n    if (length <= collectionSizeLimit) return;\n    throw new DecodeException(\n        \"Unable to decode %s of length %d, exceeded maximum collection size of %d\",\n        collectionType, length, collectionSizeLimit);\n  }\n\n  private Object decodeObject(int len) throws IOException {\n    assertLength(PklBinaryCode.OBJECT, len, 3);\n    currPath.push(\"'object\");\n\n    var className = unpacker.unpackString();\n    if (className.isBlank()) {\n      throw new DecodeException(\"Unexpected blank object class name\");\n    }","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/util/pklbinary/AbstractPklBinaryDecoder.java#L166-L202","documentation":"DecodeException thrown by the default branch of decodeNonPrimitive()'s switch: the code is a known PklBinaryCode but not one this decoder handles (e.g. codes reserved or handled only by specialized subclasses). The decoder encountered a structurally valid but unsupported object code.","triggerScenarios":"A PklBinaryCode value that maps in the enum but has no case in decodeNonPrimitive's switch (reserved/extension codes); decoding a payload containing codes intended for a different decoder implementation; version skew where new codes exist in the enum but are unhandled.","commonSituations":"Mixing decoder implementations across Pkl versions; payloads containing newer structure types decoded by an older consumer; custom decoder subclasses that did not override handling for all codes.","solutions":["Upgrade the Pkl dependency so decodeNonPrimitive handles the reported code","Regenerate the payload avoiding the unsupported structure type","If maintaining a subclass, add handling (or an explicit error) for the missing code case","Check producer/consumer version compatibility for the binary format"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Producer side: restrict emitted PklBinaryCodes to those the consumer's decoder handles\nSet<PklBinaryCode> supported = Set.of(OBJECT, MAP, MAPPING, LIST, LISTING, SET, INTSEQ, REGEX, CLASS, TYPEALIAS, BYTES);\nif (!supported.contains(code)) {\n  throw new IllegalStateException(\"consumer cannot decode \" + code);\n}","typeGuard":null,"tryCatchPattern":"try {\n  Object v = decoder.decode(bytes);\n} catch (DecodeException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Unrecognized object code\")) {\n    // upgrade consumer or re-produce payload avoiding the unsupported code\n  } else throw e;\n}","preventionTips":["Upgrade the Pkl dependency when producers emit newer structure codes","Restrict exported value types to the common subset supported by all consumers","Test decode compatibility across every supported producer/consumer version pair","If subclassing, cover every PklBinaryCode case in the decode switch"],"tags":["pkl-binary","decoding","unsupported-operation","version-mismatch"],"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-17T15:17:12.973Z"}