{"record":{"id":"fa1af684478eb1bf","repo":"apache/iceberg","slug":"failed-to-encode-partition","errorCode":null,"errorMessage":"Failed to encode partition","messagePattern":"Failed to encode partition","errorType":"exception","errorClass":"UncheckedIOException","httpStatus":null,"severity":"error","filePath":"flink/v1.20/flink/src/main/java/org/apache/iceberg/flink/maintenance/operator/StructLikeSerializer.java","lineNumber":88,"sourceCode":"\n    return new SerializedEqualityValues(baos.toByteArray());\n  }\n\n  public byte[] encodePartition(StructLike partition, Types.StructType partitionType) {\n    List<Types.NestedField> fields = partitionType.fields();\n    if (fields.isEmpty()) {\n      return EMPTY_PARTITION;\n    }\n\n    baos.reset();\n    try {\n      for (int i = 0; i < fields.size(); i++) {\n        writeField(partition, i, fields.get(i).type());\n      }\n\n      dos.flush();\n    } catch (IOException e) {\n      throw new UncheckedIOException(\"Failed to encode partition\", e);\n    }\n\n    return baos.toByteArray();\n  }\n\n  public static StructLike decodePartition(byte[] encoded, Types.StructType partitionType) {\n    PartitionData partition = new PartitionData(partitionType);\n    List<Types.NestedField> fields = partitionType.fields();\n    if (fields.isEmpty()) {\n      return partition;\n    }\n\n    try (DataInputStream dis = new DataInputStream(new ByteArrayInputStream(encoded))) {\n      for (int i = 0; i < fields.size(); i++) {\n        boolean isNull = dis.readBoolean();\n        if (isNull) {\n          partition.set(i, null);\n        } else {","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v1.20/flink/src/main/java/org/apache/iceberg/flink/maintenance/operator/StructLikeSerializer.java#L70-L106","documentation":"StructLikeSerializer.encodePartition converts a partition StructLike into bytes using the partition type's fields; any IOException during writing is wrapped in an UncheckedIOException with this message. It indicates partition values could not be encoded for keying/storage.","triggerScenarios":"Calling encodePartition where writeField throws IOException while serializing one of the partition spec's fields (unsupported type or writer failure).","commonSituations":"Partition specs containing exotic types not covered by the serializer's writeField, or internal I/O errors while writing to the buffer.","solutions":["Check the wrapped IOException cause and the partition type of the table.","Verify all partition field types are supported by the Flink sink serializer.","Upgrade Iceberg if a supported type fails; otherwise file a bug with the partition spec."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Verify partition spec field types are supported before encodePartition\npartitionType.fields().forEach(f -> check(supportedTypes.contains(f.type()), \"Unsupported partition type: \" + f.type()));","typeGuard":null,"tryCatchPattern":"try { byte[] encoded = serializer.encodePartition(partition, partitionType); } catch (UncheckedIOException e) { LOG.error(\"Partition encode failed\", e.getCause()); throw e; }","preventionTips":["Avoid exotic partition transforms producing types not handled by the Flink serializer","Inspect the IOException cause to identify the failing partition field","Report reproducible failures on supported types as Iceberg bugs"],"tags":["flink","serialization","partitioning"],"backgroundTag":"json-serialization-failed","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"}