{"record":{"id":"a60edd21097ce2f1","repo":"apache/flink","slug":"delimiter-must-not-be-null-a60edd","errorCode":null,"errorMessage":"Delimiter must not be null","messagePattern":"Delimiter 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":149,"sourceCode":"        return commentPrefix;\n    }\n\n    public void setCommentPrefix(String commentPrefix) {\n        if (commentPrefix != null) {\n            this.commentPrefix = commentPrefix.getBytes(getCharset());\n        } else {\n            this.commentPrefix = null;\n        }\n        this.commentPrefixString = commentPrefix;\n    }\n\n    public byte[] getFieldDelimiter() {\n        return fieldDelim;\n    }\n\n    public void setFieldDelimiter(String delimiter) {\n        if (delimiter == null) {\n            throw new IllegalArgumentException(\"Delimiter must not be null\");\n        }\n\n        this.fieldDelim = delimiter.getBytes(getCharset());\n        this.fieldDelimString = delimiter;\n    }\n\n    public boolean isLenient() {\n        return lenient;\n    }\n\n    public void setLenient(boolean lenient) {\n        this.lenient = lenient;\n    }\n\n    public boolean isSkippingFirstLineAsHeader() {\n        return skipFirstLineAsHeader;\n    }\n","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/common/io/GenericCsvInputFormat.java#L131-L167","documentation":"Thrown by GenericCsvInputFormat.setFieldDelimiter(String) when the delimiter argument is null. The delimiter is converted to bytes using the configured charset; a null value cannot be encoded and the field parser relies on a non-null byte delimiter to tokenize records, so it is rejected eagerly.","triggerScenarios":"Calling setFieldDelimiter(null); passing a delimiter variable that was never initialized; a config-driven delimiter that resolved to null.","commonSituations":"Building a CSV reader where the delimiter comes from an optional config that wasn't supplied; refactoring that drops the assignment; tests that pass null to probe defaults.","solutions":["Pass a non-null delimiter string (e.g., \",\" or \"\\t\").","If the delimiter is optional, default it before calling: String d = config != null ? config : \",\".","Use the constructor / builder variant that accepts a delimiter directly to avoid forgetting the call."],"exampleFix":"// before\ncsvFormat.setFieldDelimiter(delimiter); // delimiter is null\n\n// after\nString delimiter = Optional.ofNullable(cfgDelimiter).orElse(\",\");\ncsvFormat.setFieldDelimiter(delimiter);","handlingStrategy":"validation","validationCode":"String delim = Optional.ofNullable(configDelimiter).orElse(\",\");\nObjects.requireNonNull(delim, \"CSV delimiter must not be null\");\ncsvFormat.setFieldDelimiter(delim);","typeGuard":"static boolean isValidDelimiter(String d) {\n    return d != null && !d.isEmpty();\n}","tryCatchPattern":null,"preventionTips":["Default optional delimiters to \",\" before calling setFieldDelimiter.","Treat delimiter as a required config field in schema builders.","Unit test the CSV builder with a missing delimiter to confirm it defaults rather than throws."],"tags":["flink","csv","input-format","null-check","configuration"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}