apache/flink · error · IllegalArgumentException
Line length limit must be at least 1.
Error message
Line length limit must be at least 1.
What it means
DelimitedInputFormat uses lineLengthLimit as a safety bound to detect unparseable/malformed records (records spanning more bytes than the limit abort reading with an IOException). A limit < 1 is meaningless and would reject every record, so setLineLengthLimit enforces a minimum of 1.
Source
Thrown at flink-core/src/main/java/org/apache/flink/api/common/io/DelimitedInputFormat.java:255
public void setDelimiter(char delimiter) {
setDelimiter(String.valueOf(delimiter));
}
public void setDelimiter(String delimiter) {
if (delimiter == null) {
throw new IllegalArgumentException("Delimiter must not be null");
}
this.delimiter = delimiter.getBytes(getCharset());
this.delimiterString = delimiter;
}
public int getLineLengthLimit() {
return lineLengthLimit;
}
public void setLineLengthLimit(int lineLengthLimit) {
if (lineLengthLimit < 1) {
throw new IllegalArgumentException("Line length limit must be at least 1.");
}
this.lineLengthLimit = lineLengthLimit;
}
public int getBufferSize() {
return bufferSize;
}
public void setBufferSize(int bufferSize) {
if (bufferSize < 2) {
throw new IllegalArgumentException("Buffer size must be at least 2.");
}
this.bufferSize = bufferSize;
}
public int getNumLineSamples() {View on GitHub (pinned to 2f3c205e92)
Solutions
- Set a positive limit, e.g. format.setLineLengthLimit(1024 * 1024) for 1 MB records.
- If you intend 'effectively unlimited', set a very large value such as Integer.MAX_VALUE.
- Validate the configured limit is >= 1 before calling setLineLengthLimit.
Example fix
// before format.setLineLengthLimit(maxRecordBytes); // maxRecordBytes == 0 -> throws // after int limit = maxRecordBytes > 0 ? maxRecordBytes : Integer.MAX_VALUE; format.setLineLengthLimit(limit);
Defensive patterns
Strategy: validation
Validate before calling
int limit = configuredLineLengthLimit > 0 ? configuredLineLengthLimit : Integer.MAX_VALUE; format.setLineLengthLimit(limit);
Prevention
- Map 0/negative to a large positive value (the format has no 'unlimited' sentinel).
- Set the limit based on the largest legitimate record in your data.
- Validate config-derived limits before calling setLineLengthLimit.
When it happens
Trigger: Calling format.setLineLengthLimit(0) or any negative value.
Common situations: Misconfiguring the max record length from a property that defaulted to 0; passing -1 to mean 'unlimited' (this format has no unlimited sentinel — use a large value instead).
Related errors
- Delimiter must not be null
- Buffer size must be at least 2.
- Number of line samples must not be negative.
- Buffer size must be greater than length of delimiter.
- The block size parameter must be set and larger than 0.
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/72ebdf475b1df0ad.
Report an issue: GitHub.