{"record":{"id":"7cec4841ee62d494","repo":"eclipse-vertx/vert.x","slug":"cannot-read-directory-file-it-s-not-a-director","errorCode":null,"errorMessage":"Cannot read directory ${file}. It's not a directory","messagePattern":"Cannot read directory (.+?)\\. It's not a directory","errorType":"exception","errorClass":"FileSystemException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/file/impl/FileSystemImpl.java","lineNumber":817,"sourceCode":"      }\n    };\n  }\n\n  private BlockingAction<List<String>> readDirInternal(String path) {\n    return readDirInternal(path, null);\n  }\n\n  private BlockingAction<List<String>> readDirInternal(String p, String filter) {\n    Objects.requireNonNull(p);\n    return new BlockingAction<List<String>>() {\n      public List<String> perform() {\n        try {\n          File file = resolveFile(p);\n          if (!file.exists()) {\n            throw new FileSystemException(\"Cannot read directory \" + file + \". Does not exist\");\n          }\n          if (!file.isDirectory()) {\n            throw new FileSystemException(\"Cannot read directory \" + file + \". It's not a directory\");\n          } else {\n            FilenameFilter fnFilter;\n            if (filter != null) {\n              Pattern fnPattern = Pattern.compile(filter);\n              fnFilter = new FilenameFilter() {\n                public boolean accept(File dir, String name) {\n                  return fnPattern.matcher(name).matches();\n                }\n              };\n            } else {\n              fnFilter = null;\n            }\n            File[] files;\n            if (fnFilter == null) {\n              files = file.listFiles();\n            } else {\n              files = file.listFiles(fnFilter);\n            }","sourceCodeStart":799,"sourceCodeEnd":835,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/file/impl/FileSystemImpl.java#L799-L835","documentation":"Filesystem check in readDirInternal: the resolved path exists but is a regular file, not a directory, so its entries cannot be listed. The offending path is included in the message to distinguish this from the does-not-exist case.","triggerScenarios":"Calling FileSystem.readDir(path) with a path that points to an existing file instead of a directory.","commonSituations":"Config pointing at a file where a directory is expected (e.g. a cert file where a certs directory was expected), or a path that changed type between environments.","solutions":["Point readDir at an actual directory","Use readFile/fs.props if a file was intended"],"exampleFix":"// before\nvertx.fileSystem().readDir(\"/etc/app/config.json\");\n// after\nvertx.fileSystem().readDir(\"/etc/app\");","handlingStrategy":"validation","validationCode":"io.vertx.core.file.FileProps props = vertx.fileSystem().propsBlocking(path);\nif (props == null || !props.isDirectory()) {\n  throw new IllegalArgumentException(\"Not a directory: \" + path);\n}","typeGuard":null,"tryCatchPattern":"try {\n  fs.readDir(path);\n} catch (FileSystemException e) {\n  logger.warn(\"{} is not a directory\", path);\n}","preventionTips":["Validate path type with FileSystem.props before readDir","Double-check config values that supply directories vs files","Add unit tests asserting the configured paths are directories"],"tags":["filesystem","io","directory"],"backgroundTag":"path-is-not-a-directory","analyzedSha":"fb308bd8c3f12c79f4ae89bef67fadf6c80d036e","analyzedAt":"2026-09-06T11:37:12.241Z","contentChangedAt":"2026-09-06T11:37:12.241Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}