apache/flink · error · IOException
The file path is null.
Error message
The file path is null.
What it means
Thrown by FileOutputFormat.open as an IOException when the outputFilePath field is null at the point the open method tries to resolve the filesystem. This is a secondary guard beyond configure(); it fires if the path was somehow cleared between configure() and open(), or if a subclass bypasses configure().
Source
Thrown at flink-core/src/main/java/org/apache/flink/api/common/io/FileOutputFormat.java:206
throw new IllegalArgumentException(
"TaskNumber: " + taskNumber + ", numTasks: " + numTasks);
}
if (LOG.isDebugEnabled()) {
LOG.debug(
"Opening stream for output ("
+ (taskNumber + 1)
+ "/"
+ numTasks
+ "). WriteMode="
+ writeMode
+ ", OutputDirectoryMode="
+ outputDirectoryMode);
}
Path p = this.outputFilePath;
if (p == null) {
throw new IOException("The file path is null.");
}
final FileSystem fs = p.getFileSystem();
// if this is a local file system, we need to initialize the local output directory here
if (!fs.isDistributedFS()) {
if (numTasks == 1 && outputDirectoryMode == OutputDirectoryMode.PARONLY) {
// output should go to a single file
// prepare local output path. checks for write mode and removes existing files in
// case of OVERWRITE mode
if (!fs.initOutPathLocalFS(p, writeMode, false)) {
// output preparation failed! Cancel task.
throw new IOException(
"Output path '"
+ p.toString()
+ "' could not be initialized. Canceling task...");View on GitHub (pinned to 2f3c205e92)
Solutions
- Do not mutate outputFilePath after configure(); keep the lifecycle intact (configure → open).
- In tests, call configure(...) before open(...) and ensure a path was set.
- If subclassing, do not null out outputFilePath.
Example fix
// before: test calls open without configure / path format.open(ctx); // after format.setOutputFilePath(new Path(tempDir.toUri())); format.configure(new Configuration()); format.open(ctx);
Defensive patterns
Strategy: validation
Validate before calling
// In tests: configure + set path before open format.setOutputFilePath(new Path(tempDir.toUri())); format.configure(new Configuration()); format.open(ctx);
Prevention
- Keep the configure → open lifecycle intact; do not null the path between them.
- Call configure(...) before open(...) in manual/test invocations.
- Subclasses must not clear outputFilePath.
When it happens
Trigger: outputFilePath set to null after configure() but before open(); a subclass overriding configure without keeping the path; running open without the runtime invoking configure (custom invocation order).
Common situations: Subclass that resets state between phases; a serialized format whose transient path handling is broken; manual open() invocation in tests without configure().
Related errors
- Output file path may not be null.
- TaskNumber: {}, numTasks: {}
- Output path '{}' could not be initialized. Canceling task...
- Output directory '{}' could not be created. Canceling task..
- Output path could not be initialized.
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/9e7ab4196d2d261a.
Report an issue: GitHub.