{"record":{"id":"2c5cd4c252ca9cd2","repo":"apache/flink","slug":"the-record-must-not-be-null-2c5cd4","errorCode":null,"errorMessage":"The record must not be null.","messagePattern":"The record must not be null\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/common/typeutils/base/array/DoublePrimitiveArraySerializer.java","lineNumber":71,"sourceCode":"        double[] copy = new double[from.length];\n        System.arraycopy(from, 0, copy, 0, from.length);\n        return copy;\n    }\n\n    @Override\n    public double[] copy(double[] from, double[] reuse) {\n        return copy(from);\n    }\n\n    @Override\n    public int getLength() {\n        return -1;\n    }\n\n    @Override\n    public void serialize(double[] record, DataOutputView target) throws IOException {\n        if (record == null) {\n            throw new IllegalArgumentException(\"The record must not be null.\");\n        }\n\n        final int len = record.length;\n        target.writeInt(len);\n        for (int i = 0; i < len; i++) {\n            target.writeDouble(record[i]);\n        }\n    }\n\n    @Override\n    public double[] deserialize(DataInputView source) throws IOException {\n        final int len = source.readInt();\n        double[] result = new double[len];\n\n        for (int i = 0; i < len; i++) {\n            result[i] = source.readDouble();\n        }\n","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/common/typeutils/base/array/DoublePrimitiveArraySerializer.java#L53-L89","documentation":"DoublePrimitiveArraySerializer writes the array length then each double. serialize() rejects null because a null array has no length to emit and primitive-array type information is non-nullable by contract.","triggerScenarios":"Calling serialize(null, target) on the double[] serializer — a field typed double[] that resolved to null at runtime.","commonSituations":"A numeric/vector field typed double[] that is null due to a null source value; a UDF returning null where a double array is expected; a nullable SQL column mapped to a primitive double[].","solutions":["Initialize double[] fields to an empty array instead of null before the sink/state.","Filter out records with null arrays upstream.","If nullability is legitimate, switch to an object/nullable type (e.g., Double[] or a Row with null handling).","Add a null check in your mapper to default null arrays to empty."],"exampleFix":"// before: out.values may be null -> serializer.serialize(values) throws\n// after: data.map(r -> { if (r.values == null) r.values = new double[0]; return r; })","handlingStrategy":"validation","validationCode":"// Validate before serialize\ndouble[] safe = record == null ? new double[0] : record;\nserializer.serialize(safe, target);","typeGuard":null,"tryCatchPattern":"try {\n    serializer.serialize(record, target);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().equals(\"The record must not be null.\")) {\n        record = new double[0];\n        serializer.serialize(record, target);\n    } else throw e;\n}","preventionTips":["Default double[] fields to an empty array rather than null.","Sanitize null double arrays in a mapper before the sink/state.","Use a nullable type representation if nulls are legitimate."],"tags":["serialization","null-check","primitive-array"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}