{"record":{"id":"3dd00f9c7865375c","repo":"apache/flink","slug":"field-types-must-not-be-null","errorCode":null,"errorMessage":"Field types must not be null.","messagePattern":"Field types must not be null\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/common/io/GenericCsvInputFormat.java","lineNumber":204,"sourceCode":"            return this.fieldTypes;\n        } else {\n            // sparse type array which we made dense for internal book keeping.\n            // create a sparse copy to return\n            Class<?>[] types = new Class<?>[this.fieldIncluded.length];\n\n            for (int i = 0, k = 0; i < this.fieldIncluded.length; i++) {\n                if (this.fieldIncluded[i]) {\n                    types[i] = this.fieldTypes[k++];\n                }\n            }\n\n            return types;\n        }\n    }\n\n    protected void setFieldTypesGeneric(Class<?>... fieldTypes) {\n        if (fieldTypes == null) {\n            throw new IllegalArgumentException(\"Field types must not be null.\");\n        }\n\n        this.fieldIncluded = new boolean[fieldTypes.length];\n        ArrayList<Class<?>> types = new ArrayList<Class<?>>();\n\n        // check if we support parsers for these types\n        for (int i = 0; i < fieldTypes.length; i++) {\n            Class<?> type = fieldTypes[i];\n\n            if (type != null) {\n                if (FieldParser.getParserForType(type) == null) {\n                    throw new IllegalArgumentException(\n                            \"The type '\"\n                                    + type.getName()\n                                    + \"' is not supported for the CSV input format.\");\n                }\n                types.add(type);\n                fieldIncluded[i] = true;","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/common/io/GenericCsvInputFormat.java#L186-L222","documentation":"Thrown by GenericCsvInputFormat.setFieldTypesGeneric(Class<?>... fieldTypes) when the fieldTypes array itself is null. The method allocates the fieldIncluded mask of length fieldTypes.length, so a null array cannot proceed. Note: individual null entries inside the array are allowed and mean 'skip this position'.","triggerScenarios":"Calling setFieldTypesGeneric((Class<?>[]) null); a subclass passing a null types array from a config-driven builder; varargs misuse that resolves to a null array.","commonSituations":"Dynamic CSV schema where the type array was not built because no columns were configured; refactoring that leaves the types array uninitialized.","solutions":["Pass a non-null Class<?>[] (even an empty array if zero columns are selected).","Guard the builder: types = types != null ? types : new Class<?>[0] before calling.","Ensure your subclass constructs the types array from a validated schema."],"exampleFix":"// before\nformat.setFieldTypesGeneric(types); // types is null\n\n// after\nClass<?>[] types = schema != null ? schema.getTypes() : new Class<?>[0];\nformat.setFieldTypesGeneric(types);","handlingStrategy":"validation","validationCode":"Class<?>[] types = schema != null ? schema.getTypes() : new Class<?>[0];\nObjects.requireNonNull(types, \"field types array must not be null\");\nformat.setFieldTypesGeneric(types);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Construct the types array from a validated schema; never pass null.","Default to an empty array when no columns are configured.","Centralize CSV schema building so the array is always initialized."],"tags":["flink","csv","input-format","null-check","schema"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}