{"record":{"id":"65040eaac645a8f2","repo":"apache/iceberg","slug":"unsupported-primitive-type","errorCode":null,"errorMessage":"Unsupported primitive type: ","messagePattern":"Unsupported primitive type: ","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"api/src/main/java/org/apache/iceberg/variants/SerializedPrimitive.java","lineNumber":104,"sourceCode":"      case DECIMAL8:\n        return 9;\n      case DECIMAL16:\n        return 17;\n      case UUID:\n        return 16;\n      case BINARY:\n      case STRING:\n        Preconditions.checkArgument(\n            PRIMITIVE_OFFSET + 4 <= value.remaining(),\n            \"Invalid variant primitive: %s size field extends past buffer\",\n            type);\n        int size = ByteBuffers.readLittleEndianInt32(value, PRIMITIVE_OFFSET);\n        Preconditions.checkArgument(\n            size >= 0, \"Invalid variant primitive: negative %s size %s\", type, size);\n        return 4L + size;\n    }\n\n    throw new UnsupportedOperationException(\"Unsupported primitive type: \" + type);\n  }\n\n  private Object read() {\n    switch (type) {\n      case NULL:\n        return null;\n      case BOOLEAN_TRUE:\n        return true;\n      case BOOLEAN_FALSE:\n        return false;\n      case INT8:\n        return ByteBuffers.readLittleEndianInt8(value, PRIMITIVE_OFFSET);\n      case INT16:\n        return ByteBuffers.readLittleEndianInt16(value, PRIMITIVE_OFFSET);\n      case INT32:\n      case DATE:\n        return ByteBuffers.readLittleEndianInt32(value, PRIMITIVE_OFFSET);\n      case INT64:","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/api/src/main/java/org/apache/iceberg/variants/SerializedPrimitive.java#L86-L122","documentation":"SerializedPrimitive.requiredBytes (via payloadSize) computes the payload length for a decoded primitive. If the primitive's physical type has no size rule implemented in this reader, this UnsupportedOperationException is thrown — the serialized variant contains a primitive type this code cannot size.","triggerScenarios":"Calling get()/requiredBytes() on a SerializedPrimitive whose PhysicalType falls through the payloadSize switch (an unsupported/unknown primitive type), typically from malformed or newer-spec variant data.","commonSituations":"Reading variants produced by a newer library version with additional primitive types; corrupted binary variant values; manually constructed buffers with invalid type headers.","solutions":["Upgrade the Iceberg version so the type is supported in payloadSize","Validate the variant's primitive type codes before deserialization","Re-write the data with a writer version compatible with the reader"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"boolean supported = java.util.EnumSet.allOf(PhysicalType.class).contains(p.type());","tryCatchPattern":"try {\n  long size = primitive.requiredBytes();\n} catch (UnsupportedOperationException e) {\n  // unsupported primitive type; skip or upgrade reader\n}","preventionTips":["Check primitive.type() against supported types before calling get()","Upgrade Iceberg when reading data written by newer versions","Validate binary variant values before deserialization"],"tags":["variants","serialization","unsupported"],"backgroundTag":"unsupported-operation","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}