apache/flink · error · IllegalArgumentException
The minimum split size cannot be negative.
Error message
The minimum split size cannot be negative.
What it means
minSplitSize is a lower bound on input split size used by the split assignment logic. A negative value has no physical meaning (splits cannot have negative size), so FileInputFormat.setMinSplitSize rejects it with IllegalArgumentException. Zero and positive values are accepted.
Source
Thrown at flink-core/src/main/java/org/apache/flink/api/common/io/FileInputFormat.java:322
/**
* Sets multiple paths of files to be read.
*
* @param filePaths The paths of the files to read.
*/
public void setFilePaths(Path... filePaths) {
if (filePaths.length < 1) {
throw new IllegalArgumentException("At least one file path must be specified.");
}
this.filePaths = filePaths;
}
public long getMinSplitSize() {
return minSplitSize;
}
public void setMinSplitSize(long minSplitSize) {
if (minSplitSize < 0) {
throw new IllegalArgumentException("The minimum split size cannot be negative.");
}
this.minSplitSize = minSplitSize;
}
public int getNumSplits() {
return numSplits;
}
public void setNumSplits(int numSplits) {
if (numSplits < -1 || numSplits == 0) {
throw new IllegalArgumentException(
"The desired number of splits must be positive or -1 (= don't care).");
}
this.numSplits = numSplits;
}
View on GitHub (pinned to 2f3c205e92)
Solutions
- Pass a non-negative value, e.g. format.setMinSplitSize(0) to impose no minimum or a positive byte count.
- Do not call setMinSplitSize if you want the default behavior.
- Validate the computed value is >= 0 before calling.
Example fix
// before format.setMinSplitSize(minBytes); // minBytes == -1 -> throws // after long min = minBytes >= 0 ? minBytes : 0; format.setMinSplitSize(min);
Defensive patterns
Strategy: validation
Validate before calling
long min = minSplitSize >= 0 ? minSplitSize : 0; format.setMinSplitSize(min);
Prevention
- Coerce negative min split sizes to 0 (no minimum).
- Leave the setter uncalled to keep the default.
- Validate config-derived sizes at submission time.
When it happens
Trigger: Calling format.setMinSplitSize(-1) or any negative long.
Common situations: Computing min split size from a subtraction that underflows; passing -1 intending 'use default' (the format has no such sentinel — leave the setter uncalled instead); misconfiguring from a property that defaulted to -1.
Related errors
- The block size parameter must be set and larger than 0.
- Delimiter must not be null
- Line length limit must be at least 1.
- Buffer size must be at least 2.
- Number of line samples must not be negative.
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/bffdead75efc5923.
Report an issue: GitHub.