apache/flink · error · IllegalArgumentException
File path was not specified in input format or configuration
Error message
File path was not specified in input format or configuration.
What it means
FileInputFormat.configure(parameters) is called by the runtime before splits are created. If no file path was set on the format directly (getFilePaths().length == 0), it looks for the path under the FILE_PARAMETER_KEY in the Configuration. If that is also absent (null), the format cannot proceed and throws IllegalArgumentException — reading requires at least one input path.
Source
Thrown at flink-core/src/main/java/org/apache/flink/api/common/io/FileInputFormat.java:405
// --------------------------------------------------------------------------------------------
// Pre-flight: Configuration, Splits, Sampling
// --------------------------------------------------------------------------------------------
/**
* Configures the file input format by reading the file path from the configuration.
*
* @see
* org.apache.flink.api.common.io.InputFormat#configure(org.apache.flink.configuration.Configuration)
*/
@Override
public void configure(Configuration parameters) {
if (getFilePaths().length == 0) {
// file path was not specified yet. Try to set it from the parameters.
String filePath = parameters.getString(FILE_PARAMETER_KEY, null);
if (filePath == null) {
throw new IllegalArgumentException(
"File path was not specified in input format or configuration.");
} else {
setFilePath(filePath);
}
}
}
/**
* Obtains basic file statistics containing only file size. If the input is a directory, then
* the size is the sum of all contained files.
*
* @see
* org.apache.flink.api.common.io.InputFormat#getStatistics(org.apache.flink.api.common.io.statistics.BaseStatistics)
*/
@Override
public FileBaseStatistics getStatistics(BaseStatistics cachedStats) throws IOException {
final FileBaseStatistics cachedFileStats =View on GitHub (pinned to 2f3c205e92)
Solutions
- Call format.setFilePath(...) before submitting the job.
- If using config-based paths, set the value under FILE_PARAMETER_KEY in the Configuration passed to configure().
- Add a startup assertion that getFilePaths().length > 0 after format configuration.
Example fix
// before
FileInputFormat<MyType> format = new MyFormat();
env.readFile(format, null); // no path set -> configure() throws
// after
FileInputFormat<MyType> format = new MyFormat();
format.setFilePath("hdfs:///data/input");
env.readFile(format, "hdfs:///data/input"); Defensive patterns
Strategy: validation
Validate before calling
// After configuring the format, assert a path is present before submission.
if (format.getFilePaths().length == 0) {
throw new IllegalStateException("FileInputFormat has no input path configured");
}
// or set it from configuration:
Configuration cfg = new Configuration();
cfg.setString(FileInputFormat.FILE_PARAMETER_KEY, "hdfs:///data/input");
format.configure(cfg); Prevention
- Always call setFilePath during format construction.
- If config-driven, set the value under FILE_PARAMETER_KEY before configure().
- Add a submission-time assertion that getFilePaths().length > 0.
When it happens
Trigger: Submitting a job whose FileInputFormat subclass had neither setFilePath/setFilePaths called nor a value set under the configuration key 'flink.input.file.path' (FILE_PARAMETER_KEY). Common when building a format from a generic factory that forgot to set the path.
Common situations: Programmatic job assembly where the path was set on a different (wrong) format instance; configuration-driven jobs where the path key is missing from the submitted config; refactoring that moved setFilePath behind a conditional that evaluated false.
Related errors
- File path cannot be null.
- 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.
- You must have forgotten to call open() on your input format.
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/cbc496b690d89519.
Report an issue: GitHub.