apache/flink · error · IllegalArgumentException
File path cannot be null.
Error message
File path cannot be null.
What it means
FileInputFormat.setFilePath(String) rejects a null path immediately with IllegalArgumentException. An empty string is tolerated (treated as a placeholder Path, a legacy workaround for the job-submission preview graph), but null is not, because the format must resolve a concrete filesystem location.
Source
Thrown at flink-core/src/main/java/org/apache/flink/api/common/io/FileInputFormat.java:255
// --------------------------------------------------------------------------------------------
// Getters/setters for the configurable parameters
// --------------------------------------------------------------------------------------------
/**
* Returns the paths of all files to be read by the FileInputFormat.
*
* @return The list of all paths to read.
*/
public Path[] getFilePaths() {
if (this.filePaths == null) {
return new Path[0];
}
return this.filePaths;
}
public void setFilePath(String filePath) {
if (filePath == null) {
throw new IllegalArgumentException("File path cannot be null.");
}
// TODO The job-submission web interface passes empty args (and thus empty
// paths) to compute the preview graph. The following is a workaround for
// this situation and we should fix this.
// comment (Stephan Ewen) this should be no longer relevant with the current Java/Scala
// APIs.
if (filePath.isEmpty()) {
setFilePath(new Path());
return;
}
try {
this.setFilePath(new Path(filePath));
} catch (RuntimeException rex) {
throw new RuntimeException(
"Could not create a valid URI from the given file path name: "View on GitHub (pinned to 2f3c205e92)
Solutions
- Provide a non-null file path string, e.g. format.setFilePath("hdfs:///data/input").
- Validate the path is non-null before calling setFilePath.
- Use the Path overload (setFilePath(Path)) if you already have a Path object.
Example fix
// before
String path = config.get("inputPath"); // null
format.setFilePath(path); // throws
// after
String path = checkNotNull(config.get("inputPath"), "inputPath must be set");
format.setFilePath(path); Defensive patterns
Strategy: validation
Validate before calling
String path = Preconditions.checkNotNull(configuredPath, "file path must be set"); format.setFilePath(path);
Prevention
- Use Preconditions.checkNotNull on config-derived paths.
- Fail the job early at submission if the path is missing.
- Prefer the typed Path overload when you already have a Path.
When it happens
Trigger: Calling format.setFilePath((String) null); passing a variable that was never assigned; reading a path from configuration that returned null and forwarding it directly.
Common situations: Building an input format programmatically from a config map where the path key is missing; copy-paste where the path variable name is misspelled/unset; refactoring that leaves a null path reference.
Related errors
- File path must not be null.
- At least one file path must be specified.
- 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/7cf49a8b5cf55e7f.
Report an issue: GitHub.