{"record":{"id":"6d59818b3eead6c7","repo":"apache/iceberg","slug":"failed-to-decode-partition-6d5981","errorCode":null,"errorMessage":"Failed to decode partition","messagePattern":"Failed to decode partition","errorType":"exception","errorClass":"UncheckedIOException","httpStatus":null,"severity":"error","filePath":"flink/v2.2/flink/src/main/java/org/apache/iceberg/flink/maintenance/operator/StructLikeSerializer.java","lineNumber":121,"sourceCode":"        boolean isNull = dis.readBoolean();\n        if (isNull) {\n          partition.set(i, null);\n        } else {\n          int length = dis.readInt();\n          byte[] bytes = new byte[length];\n          dis.readFully(bytes);\n          Object value = Conversions.fromByteBuffer(fields.get(i).type(), ByteBuffer.wrap(bytes));\n          // Conversions returns CharBuffer for STRING; PartitionData (and the manifest writer)\n          // expects String.\n          if (value instanceof CharSequence cs && !(value instanceof String)) {\n            value = cs.toString();\n          }\n\n          partition.set(i, value);\n        }\n      }\n    } catch (IOException e) {\n      throw new UncheckedIOException(\"Failed to decode partition\", e);\n    }\n\n    return partition;\n  }\n\n  private void writeField(StructLike struct, int pos, Type fieldType) throws IOException {\n    Object value = struct.get(pos, Object.class);\n    if (value == null) {\n      dos.writeBoolean(true);\n      return;\n    }\n\n    dos.writeBoolean(false);\n    ByteBuffer buf = Conversions.toByteBuffer(fieldType, value);\n    dos.writeInt(buf.remaining());\n    dos.write(buf.array(), buf.arrayOffset() + buf.position(), buf.remaining());\n  }\n}","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v2.2/flink/src/main/java/org/apache/iceberg/flink/maintenance/operator/StructLikeSerializer.java#L103-L139","documentation":"StructLikeSerializer.decodePartition reads a previously encoded partition from bytes and sets values on a partition StructLike; IOExceptions are wrapped in UncheckedIOException with this message. It occurs when the byte array does not match the expected partition-type layout, i.e. corrupt or version-mismatched encoded data.","triggerScenarios":"decodePartition called with bytes that were not produced by encodePartition for the same partition type — e.g. restored operator state written by a different schema/version, or corrupted index payload.","commonSituations":"Restoring checkpoints across schema evolution (partition spec changed), or cross-version state restore where the encoded layout changed.","solutions":["Ensure the partition type used for decoding matches the one used at encoding time.","Restore from a checkpoint created with the same Iceberg version and unchanged partition spec.","If partition spec evolved, reprocess from scratch instead of restoring old encoded state."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Confirm the partition type used to encode matches the one used to decode:\nif (!partitionType.equals(encodedAgainstType)) {\n  throw new IllegalStateException(\"Partition type mismatch between encode and decode\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  partition = StructLikeSerializer.decodePartition(bytes, partitionType);\n} catch (UncheckedIOException e) {\n  LOG.error(\"Corrupt or version-mismatched partition payload\", e);\n  throw e;\n}","preventionTips":["Do not restore checkpoints across partition-spec evolution without reprocessing.","Keep Iceberg versions consistent between checkpoint write and restore."],"tags":["flink","deserialization","unchecked-io"],"backgroundTag":"json-decode-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"}