apache/flink · error · IllegalArgumentException
At least one file path must be specified.
Error message
At least one file path must be specified.
What it means
setFilePaths(Path...) (and the String varargs overload that feeds it) requires at least one path. An empty varargs array means no input is configured, which the format cannot use to read data, so it rejects with IllegalArgumentException rather than silently doing nothing.
Source
Thrown at flink-core/src/main/java/org/apache/flink/api/common/io/FileInputFormat.java:311
*
* @param filePaths The paths of the files to read.
*/
public void setFilePaths(String... filePaths) {
Path[] paths = new Path[filePaths.length];
for (int i = 0; i < paths.length; i++) {
paths[i] = new Path(filePaths[i]);
}
setFilePaths(paths);
}
/**
* 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;View on GitHub (pinned to 2f3c205e92)
Solutions
- Ensure at least one path is passed, e.g. format.setFilePaths(path1, path2).
- Guard the call: only invoke setFilePaths when the path collection is non-empty.
- If no input is genuinely available, skip creating/configuring the source rather than passing an empty array.
Example fix
// before
Path[] paths = discoverInputs().toArray(new Path[0]); // empty
format.setFilePaths(paths); // throws
// after
List<Path> discovered = discoverInputs();
if (!discovered.isEmpty()) {
format.setFilePaths(discovered.toArray(new Path[0]));
} else {
throw new IllegalStateException("No input files discovered");
} Defensive patterns
Strategy: validation
Validate before calling
List<Path> paths = discoverInputs();
if (paths.isEmpty()) {
throw new IllegalStateException("No input files discovered");
}
format.setFilePaths(paths.toArray(new Path[0])); Prevention
- Guard dynamic path lists for emptiness before setFilePaths.
- Fail the job explicitly when no inputs are found rather than passing an empty array.
- Unit-test the discovery logic against an empty directory.
When it happens
Trigger: Calling format.setFilePaths() with no arguments, or setFilePaths(new Path[0]); passing an empty list/array converted to a varargs call.
Common situations: Dynamically building the path list from a filter that matched nothing; spreading an empty collection into the varargs call; refactoring that produced an empty array.
Related errors
- File path cannot be null.
- File path must not be null.
- The block size parameter must be set and larger than 0.
- Delimiter must not be null
- Line length limit must be at least 1.
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/1ba3ba13d9959484.
Report an issue: GitHub.