{"record":{"id":"0bdfcdf597e4195b","repo":"apache/druid","slug":"no-directory-exists-on-path-s","errorCode":null,"errorMessage":"No directory exists on path [%s]","messagePattern":"No directory exists on path \\[(.+?)\\]","errorType":"exception","errorClass":"org.apache.druid.java.util.common.IAE","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/storage/local/LocalFileStorageConnector.java","lineNumber":158,"sourceCode":"  /**\n   * Deletes the files and sub dirs present at the basePath + dirName. Also removes the dirName\n   *\n   * @param dirName path\n   * @throws IOException thrown in case of errors.\n   */\n  @Override\n  public void deleteRecursively(String dirName) throws IOException\n  {\n    log.debug(\"Deleting directory at path: [%s]\", dirName);\n    FileUtils.deleteDirectory(fileWithBasePath(dirName));\n  }\n\n  @Override\n  public Iterator<String> listDir(String dirName)\n  {\n    File directory = fileWithBasePath(dirName);\n    if (!directory.exists()) {\n      throw new IAE(\"No directory exists on path [%s]\", dirName);\n    }\n    if (!directory.isDirectory()) {\n      throw new IAE(\"Cannot list contents of [%s] since it is not a directory\", dirName);\n    }\n    File[] files = directory.listFiles();\n    if (files == null) {\n      throw new ISE(\"Unable to fetch the file list from the path [%s]\", dirName);\n    }\n    return Arrays.stream(files).map(File::getName).iterator();\n  }\n\n  public File getBasePath()\n  {\n    return basePath;\n  }\n\n  private File fileWithBasePath(String path)\n  {","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/storage/local/LocalFileStorageConnector.java#L140-L176","documentation":"LocalFileStorageConnector.listDir throws IAE when the requested directory does not exist under the base path, before attempting to list contents. A separate IAE follows if the path exists but is not a directory.","triggerScenarios":"listDir(dirName) where fileWithBasePath(dirName).exists() is false: never-created export dir, directory already deleted by cleanup, wrong relative dir name, or case mismatch on case-sensitive filesystems.","commonSituations":"Listing an export directory before the export task created it; cleanup jobs removing dirs while being listed; misconfigured base dir so relative paths resolve differently than expected.","solutions":["Verify the directory exists (ls under the connector base path) and correct the dir name/casing.","Create the directory if your workflow expects it to exist (Files.createDirectories) before listing.","Check for races with cleanup/delete jobs and coordinate or retry.","Confirm the connector's base path configuration matches where files were actually written."],"exampleFix":"// before\nIterator<String> it = connector.listDir(\"exports/2024-06\"); // may not exist\n// after\nFile dir = new File(basePath, \"exports/2024-06\");\nif (!dir.isDirectory()) {\n  return Collections.emptyIterator();\n}\nIterator<String> it = connector.listDir(\"exports/2024-06\");","handlingStrategy":"validation","validationCode":"File d = new File(basePath, dirName);\nif (!d.isDirectory()) { Files.createDirectories(d.toPath()); }","typeGuard":"boolean isDir(String p) { File d = new File(basePath, p); return d.exists() && d.isDirectory(); }","tryCatchPattern":"try { it = connector.listDir(dirName); } catch (IllegalArgumentException e) { log.warn(e, \"missing dir %s\", dirName); it = Collections.emptyIterator(); }","preventionTips":["Create expected directories before listing (Files.createDirectories).","Fix base-dir configuration so relative names resolve correctly.","Handle races with cleanup jobs via retry or existence checks.","Return empty iterators for absent optional directories rather than failing."],"tags":["local-storage","list","directory"],"backgroundTag":"directory-not-found","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}