{"record":{"id":"be2ecc95237c1f1f","repo":"apache/iceberg","slug":"could-not-read-object","errorCode":null,"errorMessage":"Could not read object ","messagePattern":"Could not read object ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/util/SerializationUtil.java","lineNumber":84,"sourceCode":"      return baos.toByteArray();\n    } catch (IOException e) {\n      throw new UncheckedIOException(\"Failed to serialize object\", e);\n    }\n  }\n\n  @SuppressWarnings({\"DangerousJavaDeserialization\", \"unchecked\"})\n  public static <T> T deserializeFromBytes(byte[] bytes) {\n    if (bytes == null) {\n      return null;\n    }\n\n    try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes);\n        ObjectInputStream ois = new ObjectInputStream(bais)) {\n      return (T) ois.readObject();\n    } catch (IOException e) {\n      throw new UncheckedIOException(\"Failed to deserialize object\", e);\n    } catch (ClassNotFoundException e) {\n      throw new RuntimeException(\"Could not read object \", e);\n    }\n  }\n\n  public static String serializeToBase64(Object obj) {\n    byte[] bytes = serializeToBytes(obj);\n    return new String(Base64.getMimeEncoder().encode(bytes), StandardCharsets.UTF_8);\n  }\n\n  public static <T> T deserializeFromBase64(String base64) {\n    if (base64 == null) {\n      return null;\n    }\n    byte[] bytes = Base64.getMimeDecoder().decode(base64.getBytes(StandardCharsets.UTF_8));\n    return deserializeFromBytes(bytes);\n  }\n}\n","sourceCodeStart":66,"sourceCodeEnd":101,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/util/SerializationUtil.java#L66-L101","documentation":"deserializeFromBytes throws a plain RuntimeException with this (trailing-space) message when ObjectInputStream.readObject cannot resolve a class on the classpath (ClassNotFoundException). It means the serialized stream is structurally valid but references a class that is not available to the deserializing JVM.","triggerScenarios":"Deserializing bytes whose payload class was written by a different classloader/application, the class was removed or renamed across versions, or the deserializing process lacks the module/jar containing the serialized type.","commonSituations":"Shipping payloads between services where only one has the concrete class; upgrading Iceberg or application code so an old stored serialized object references a deleted class; fat-jar shading changing package names.","solutions":["Add the jar/module containing the serialized class to the deserializing classpath","Confirm the class's package and serialVersionUID match on both sides (fix serialVersionUID or re-serialize)","Regenerate the payload with the current code instead of deserializing legacy bytes","Read the chained ClassNotFoundException cause to identify the exact missing class name"],"exampleFix":"// before\nT obj = SerializationUtil.deserializeFromBytes(storedBytes); // CNFE on legacy class\n// after\nMyDto dto = readJson(storedBytes); // prefer a stable format\nT obj = convert(dto);","handlingStrategy":"try-catch","validationCode":"try {\n  Class.forName(payloadClassName, false, getClass().getClassLoader());\n} catch (ClassNotFoundException e) {\n  throw new IllegalStateException(\"payload class missing from classpath: \" + payloadClassName);\n}","typeGuard":null,"tryCatchPattern":"try {\n  T obj = SerializationUtil.deserializeFromBytes(bytes);\n} catch (RuntimeException e) {\n  if (e.getCause() instanceof ClassNotFoundException) {\n    throw new IllegalStateException(\"missing class: \" + e.getCause().getMessage(), e);\n  }\n  throw e;\n}","preventionTips":["Ensure both producer and consumer ship the payload classes","Pin serialVersionUID for serialized classes","Prefer JSON/Avro over Java serialization across services","Read e.getCause() to identify the exact missing class"],"tags":["serialization","classpath"],"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"}