{"record":{"id":"b9f380e7e79c8d22","repo":"apache/iceberg","slug":"could-not-deserialize-the-writeresult-object-b9f380","errorCode":null,"errorMessage":"Could not deserialize the WriteResult object","messagePattern":"Could not deserialize the WriteResult object","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"critical","filePath":"flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/sink/WriteResultSerializer.java","lineNumber":58,"sourceCode":"  public byte[] serialize(WriteResult writeResult) throws IOException {\n    ByteArrayOutputStream out = new ByteArrayOutputStream();\n    DataOutputViewStreamWrapper view = new DataOutputViewStreamWrapper(out);\n    byte[] result = InstantiationUtil.serializeObject(writeResult);\n    view.write(result);\n    return out.toByteArray();\n  }\n\n  @Override\n  public WriteResult deserialize(int version, byte[] serialized) throws IOException {\n    if (version == 1) {\n      DataInputDeserializer view = new DataInputDeserializer(serialized);\n      byte[] resultBuf = new byte[serialized.length];\n      view.read(resultBuf);\n      try {\n        return InstantiationUtil.deserializeObject(\n            resultBuf, IcebergCommittableSerializer.class.getClassLoader());\n      } catch (ClassNotFoundException cnc) {\n        throw new IOException(\"Could not deserialize the WriteResult object\", cnc);\n      }\n    }\n    throw new IOException(\"Unrecognized version or corrupt state: \" + version);\n  }\n}\n","sourceCodeStart":40,"sourceCodeEnd":64,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/sink/WriteResultSerializer.java#L40-L64","documentation":"WriteResultSerializer.deserialize reads the serialized WriteResult bytes and calls InstantiationUtil.deserializeObject. If deserialization fails with ClassNotFoundException (the WriteResult class or its dependencies are missing from the classloader), it is wrapped in an IOException with this message.","triggerScenarios":"Deserializing a WriteResult committable whose payload requires classes not present in the task's classloader — typically when user classloading is enabled (child-first) and Iceberg classes live in a plugin/user classloader not visible to the deserializing operator.","commonSituations":"Flink classloading isolation between job stages; upgrading Iceberg across a restart with old checkpoints containing committables; missing iceberg-flink runtime jar on some TaskManagers.","solutions":["Ensure the same Iceberg Flink runtime jar is on every TaskManager's classpath (not only the client).","Set classloader.check-leaked-classloader and consider classloader.parent-first patterns for org.apache.iceberg packages.","If resuming from a savepoint across Iceberg upgrades, verify checkpointed committables are compatible or discard pending committables.","Re-run with the identical Iceberg version used when the data was serialized."],"exampleFix":"// before: runtime jar added only to client\n// after\nflink run -C file:///jars/iceberg-flink-runtime.jar ... # ship to all TMs via ./lib","handlingStrategy":"try-catch","validationCode":"// Before submitting, verify the runtime jar is deployed:\nassert Class.forName(\"org.apache.iceberg.flink.sink.WriteResult\", true,\n    Thread.currentThread().getContextClassLoader()) != null;","typeGuard":null,"tryCatchPattern":"try {\n  WriteResult r = serializer.deserialize(version, bytes);\n} catch (IOException e) {\n  if (e.getCause() instanceof ClassNotFoundException) {\n    LOG.error(\"Iceberg classes missing from task classloader; check TM classpath\", e);\n  }\n  throw e;\n}","preventionTips":["Place iceberg-flink-runtime jar in Flink lib/ or ship it to every TaskManager.","Use the same Iceberg version on client and cluster.","Avoid classloader isolation gaps for org.apache.iceberg packages."],"tags":["flink","serialization","classloader","sink"],"backgroundTag":"class-not-found","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}