apache/flink · error · IllegalArgumentException
The %s is not a directory.
Error message
The %s is not a directory.
What it means
The second validation in listFilesInDirectory: the path exists but Files.isDirectory(directory) is false, so the method throws IllegalArgumentException("The %s is not a directory."). A regular file (or special fs object) was passed where a traversable directory is required.
Source
Thrown at flink-core/src/main/java/org/apache/flink/util/FileUtils.java:576
* fileFilter}.
*
* @param directory the directory to be listed
* @param fileFilter a file filter
* @return a collection of {@code File}s
* @throws IOException if an I/O error occurs while listing the files in the given directory
*/
public static Collection<java.nio.file.Path> listFilesInDirectory(
final java.nio.file.Path directory, final Predicate<java.nio.file.Path> fileFilter)
throws IOException {
checkNotNull(directory, "directory");
checkNotNull(fileFilter, "fileFilter");
if (!Files.exists(directory)) {
throw new IllegalArgumentException(
String.format("The directory %s dose not exist.", directory));
}
if (!Files.isDirectory(directory)) {
throw new IllegalArgumentException(
String.format("The %s is not a directory.", directory));
}
final FilterFileVisitor filterFileVisitor = new FilterFileVisitor(fileFilter);
Files.walkFileTree(
directory,
EnumSet.of(FileVisitOption.FOLLOW_LINKS),
Integer.MAX_VALUE,
filterFileVisitor);
return filterFileVisitor.getFiles();
}
/**
* Computes the sum of sizes of all files in the directory and it's subdirectories.
*
* @param path the root path from which to start the calculation.View on GitHub (pinned to 2f3c205e92)
Solutions
- Point the call at the containing directory, not at a file
- Validate with Files.isDirectory(dir) and report the exact configured value in your own error message
- Delete or rename the stale file that occupies the expected directory location
Example fix
// before
Path p = Paths.get(config.get("plugins.dir")); // user set plugins.dir=/opt/flink/lib/flink-connector.jar
FileUtils.listFilesInDirectory(p, JAR_FILTER);
// after
Path p = Paths.get(config.get("plugins.dir"));
if (!Files.isDirectory(p)) throw new IllegalStateException("plugins.dir must be a directory: " + p); Defensive patterns
Strategy: validation
Validate before calling
if (!Files.isDirectory(dir)) throw new IllegalStateException("Expected a directory but got a file: " + dir); Prevention
- Point *-dir settings at folders, not jars/files
- Include the resolved path in config validation errors
When it happens
Trigger: Calling listFilesInDirectory with a path that names a regular file — e.g. pointing a 'scan this directory' option directly at a jar/zip file instead of the folder containing it.
Common situations: Configuration mistakes where a *-dir option is given a file path; a symlinked path resolving to a file; a previous run leaving a file where a directory was expected.
Related errors
- Can not create a Path from an empty string
- tempDirectories contains null entries
- {directory} is not a directory but a regular file
- The directory %s dose not exist.
- Not allowed configuration change(s) were detected:\n - {erro
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/6b38ba3be7e83913.
Report an issue: GitHub.