{"record":{"id":"fca225eb92e7793f","repo":"apache/flink","slug":"the-record-must-not-be-null","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/BooleanPrimitiveArraySerializer.java","lineNumber":71,"sourceCode":"        boolean[] copy = new boolean[from.length];\n        System.arraycopy(from, 0, copy, 0, from.length);\n        return copy;\n    }\n\n    @Override\n    public boolean[] copy(boolean[] from, boolean[] reuse) {\n        return copy(from);\n    }\n\n    @Override\n    public int getLength() {\n        return -1;\n    }\n\n    @Override\n    public void serialize(boolean[] 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.writeBoolean(record[i]);\n        }\n    }\n\n    @Override\n    public boolean[] deserialize(DataInputView source) throws IOException {\n        final int len = source.readInt();\n        boolean[] result = new boolean[len];\n\n        for (int i = 0; i < len; i++) {\n            result[i] = source.readBoolean();\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/BooleanPrimitiveArraySerializer.java#L53-L89","documentation":"BooleanPrimitiveArraySerializer writes the array length then each element. serialize() rejects null explicitly because a null array has no length to emit and Flink's primitive-array type information is non-nullable by contract.","triggerScenarios":"Calling serialize(null, target) on the boolean[] serializer — a record or field typed as boolean[] that resolved to null at runtime.","commonSituations":"A POJO/Row field typed boolean[] that is null due to upstream null input; a UDF returning null where a primitive array is expected; a nullable SQL column mapped to a primitive boolean[] type.","solutions":["Initialize array fields to an empty array instead of null before they reach the sink/state.","Filter or map out records with null arrays upstream so nulls never reach the serializer.","If nullability is legitimate, switch the type to a nullable/object form (e.g., a Row with null handling or a custom nullable TypeInfo).","Validate array fields are non-null before the serialization boundary in your mapper."],"exampleFix":"// before: out.values may be null -> serializer.serialize(values) throws\n// after: data.map(r -> { if (r.values == null) r.values = new boolean[0]; return r; })","handlingStrategy":"validation","validationCode":"// Validate before serialize\nif (record == null) {\n    throw new IllegalArgumentException(\"Refusing to serialize null boolean[]\");\n}\nboolean[] safe = record == null ? new boolean[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 boolean[0];\n        serializer.serialize(record, target);\n    } else throw e;\n}","preventionTips":["Default boolean[] fields to an empty array rather than null in POJO constructors.","Filter or sanitize null arrays in a mapper before the sink/state boundary.","If nullability is required, switch to a nullable type representation instead of a primitive array."],"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"}