{"record":{"id":"03abc649f2749a4a","repo":"apache/beam","slug":"unable-to-deserialize-description","errorCode":null,"errorMessage":"unable to deserialize {description}","messagePattern":"unable to deserialize (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/util/SerializableUtils.java","lineNumber":78,"sourceCode":"    }\n  }\n\n  /**\n   * Deserializes an object from the given array of bytes, e.g., as serialized using {@link\n   * #serializeToByteArray}, and returns it.\n   *\n   * @throws IllegalArgumentException if there are errors when deserializing, using the provided\n   *     description to identify what was being deserialized\n   */\n  public static Object deserializeFromByteArray(byte[] encodedValue, String description) {\n    try {\n      try (ObjectInputStream ois =\n          new ContextualObjectInputStream(\n              new SnappyInputStream(new ByteArrayInputStream(encodedValue)))) {\n        return ois.readObject();\n      }\n    } catch (IOException | ClassNotFoundException exn) {\n      throw new IllegalArgumentException(\"unable to deserialize \" + description, exn);\n    }\n  }\n\n  public static <T extends Serializable> T ensureSerializableRoundTrip(T value) {\n    T copy = ensureSerializable(value);\n\n    checkState(\n        value.equals(copy),\n        \"Value not equal to original after serialization, indicating that its type may not \"\n            + \"implement serialization or equals correctly.  Before: %s, after: %s\",\n        value,\n        copy);\n\n    return copy;\n  }\n\n  public static <T extends Serializable> T ensureSerializable(T value) {\n    return clone(value);","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/util/SerializableUtils.java#L60-L96","documentation":"deserializeFromByteArray decodes a byte array produced by serializeToByteArray via ObjectInputStream (Snappy-decompressed). IOException or ClassNotFoundException is rethrown as IllegalArgumentException 'unable to deserialize <description>'. Typical causes are corrupted/truncated bytes or a missing class on the runtime classpath.","triggerScenarios":"Calling deserializeFromByteArray(bytes, description) or clone() with bytes that are not Snappy-serialized Java objects, were serialized with an incompatible class version (InvalidClassException), or reference classes not present at deserialization time.","commonSituations":"Storing serialized pipeline artifacts across jobs whose classpaths changed, deserializing data written by a different serialization format, class version drift after upgrading dependencies (e.g. serialVersionUID changes).","solutions":["Ensure the bytes were produced by serializeToByteArray (Snappy+ObjectOutputStream) and are not truncated or corrupted in transit/storage.","Make the referenced class available on the runtime classpath and keep serialVersionUID stable across versions.","If classes changed, re-serialize the data with the current classes rather than deserializing old bytes.","Catch IllegalArgumentException around deserializeFromByteArray and treat it as a data-integrity error (re-fetch or recompute the bytes)."],"exampleFix":"// before\nMyObject o = SerializableUtils.deserializeFromByteArray(bytes, \"MyObject\");\n// after\ntry {\n  MyObject o = SerializableUtils.deserializeFromByteArray(bytes, \"MyObject\");\n} catch (IllegalArgumentException e) {\n  throw new DataIntegrityException(\"corrupt or incompatible serialized data\", e);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { T v = SerializableUtils.deserializeFromByteArray(bytes, desc); } catch (IllegalArgumentException e) { throw new DataIntegrityException(\"corrupt/incompatible payload: \" + desc, e); }","preventionTips":["Keep serialVersionUID stable across class versions.","Guarantee the same classpath at serialize and deserialize time.","Check byte payloads for truncation/corruption in storage or transport."],"tags":["java","beam","deserialization","classpath","data-corruption"],"backgroundTag":"class-not-found","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}