{"record":{"id":"e024eef0aa8db487","repo":"apache/flink","slug":"could-not-copy-element","errorCode":null,"errorMessage":"Could not copy element.","messagePattern":"Could not copy element\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/core/io/SimpleVersionedSerializerTypeSerializerProxy.java","lineNumber":79,"sourceCode":"                            serializerSupplier, serializerSupplier.getClass().getClassLoader()));\n        } catch (ClassNotFoundException | IOException e) {\n            throw new RuntimeException(\"Could not duplicate SimpleVersionedSerializer.\", e);\n        }\n    }\n\n    @Override\n    public T createInstance() {\n        return null;\n    }\n\n    @Override\n    public T copy(T from) {\n        SimpleVersionedSerializer<T> serializer = getSerializer();\n        try {\n            byte[] serializedFrom = serializer.serialize(from);\n            return serializer.deserialize(serializer.getVersion(), serializedFrom);\n        } catch (IOException e) {\n            throw new RuntimeException(\"Could not copy element.\", e);\n        }\n    }\n\n    @Override\n    public T copy(T from, T reuse) {\n        // the reuse is optional, we can just ignore it\n        return copy(from);\n    }\n\n    @Override\n    public int getLength() {\n        return -1;\n    }\n\n    @Override\n    public void serialize(T record, DataOutputView target) throws IOException {\n        SimpleVersionedSerializer<T> serializer = getSerializer();\n        SimpleVersionedSerialization.writeVersionAndSerialize(serializer, record, target);","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/core/io/SimpleVersionedSerializerTypeSerializerProxy.java#L61-L97","documentation":"Thrown as a RuntimeException by SimpleVersionedSerializerTypeSerializerProxy.copy(T from) when the round-trip serialize-then-deserialize used to copy an element fails with IOException. Because the proxy does not have a native copy implementation, it serializes the element to bytes and deserializes it back; any failure in the underlying SimpleVersionedSerializer (I/O error, bad data, null element) surfaces here.","triggerScenarios":"Calling copy(element) on the proxy when the underlying serializer.serialize throws; passing a null element to copy (serialize may choke); the underlying serializer has a bug producing unreadable bytes.","commonSituations":"Elements that the wrapped SimpleVersionedSerializer cannot serialize (e.g. null, or containing non-serializable fields); serializer version skew between serialize and deserialize; corrupt element state.","solutions":["Ensure the element passed to copy is non-null and serializable by the underlying SimpleVersionedSerializer.","Check the root IOException in the cause chain for the specific serialization failure.","If the element type is null-prone, guard with a null check before copy.","Verify the serializer's serialize and deserialize are mutually consistent at the same version."],"exampleFix":"// before\nT copy = proxy.copy(maybeNullElement);\n\n// after\nif (maybeNullElement == null) {\n    return null;\n}\nT copy = proxy.copy(maybeNullElement);","handlingStrategy":"try-catch","validationCode":"if (from == null) return null;","typeGuard":null,"tryCatchPattern":"try {\n    T copy = proxy.copy(element);\n} catch (RuntimeException e) {\n    if (e.getCause() instanceof IOException) {\n        // inspect the underlying serializer failure\n    }\n    throw e;\n}","preventionTips":["Guard against null elements before calling copy().","Ensure the wrapped SimpleVersionedSerializer can round-trip the element type.","Log the root IOException for diagnosis."],"tags":["serialization","type-serializer","copy","null-safety"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}