{"record":{"id":"cae60ce9862e0828","repo":"apache/hadoop","slug":"not-a-directory-dir","errorCode":null,"errorMessage":"Not a directory: ${dir}","messagePattern":"Not a directory: (.+?)","errorType":"exception","errorClass":"DiskErrorException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/DiskChecker.java","lineNumber":156,"sourceCode":"  private static void checkDirInternal(LocalFileSystem localFS, Path dir,\n                                       FsPermission expected)\n  throws DiskErrorException, IOException {\n    mkdirsWithExistsAndPermissionCheck(localFS, dir, expected);\n    checkAccessByFileMethods(localFS.pathToFile(dir));\n  }\n\n  /**\n   * Checks that the current running process can read, write, and execute the\n   * given directory by using methods of the File object.\n   * \n   * @param dir File to check\n   * @throws DiskErrorException if dir is not readable, not writable, or not\n   *   executable\n   */\n  private static void checkAccessByFileMethods(File dir)\n      throws DiskErrorException {\n    if (!dir.isDirectory()) {\n      throw new DiskErrorException(\"Not a directory: \"\n          + dir.toString());\n    }\n\n    if (!FileUtil.canRead(dir)) {\n      throw new DiskErrorException(\"Directory is not readable: \"\n                                   + dir.toString());\n    }\n\n    if (!FileUtil.canWrite(dir)) {\n      throw new DiskErrorException(\"Directory is not writable: \"\n                                   + dir.toString());\n    }\n\n    if (!FileUtil.canExecute(dir)) {\n      throw new DiskErrorException(\"Directory is not executable: \"\n                                   + dir.toString());\n    }\n  }","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/DiskChecker.java#L138-L174","documentation":"After ensuring the directory exists, DiskChecker.checkAccessByFileMethods requires dir.isDirectory(); a path that exists but is a regular file (or a symlink to one) throws DiskErrorException('Not a directory: <dir>'), failing the storage-directory health check.","triggerScenarios":"A configured data/local/log dir path that is actually a regular file; a symlink in the path resolving to a file; a path built by string concatenation landing on a file.","commonSituations":"Config values with typos pointing at a jar or log file; admins replacing a directory with a symlink to a file; deployment scripts touching a file where a dir is expected.","solutions":["Fix the configuration value to point at a real directory","If a file occupies the path, move it away and create the directory","Repair symlinks that resolve to regular files"],"exampleFix":"# before: yarn.nodemanager.local-dirs = /var/log/hadoop-yarn (a file)\n# after: point at a directory\nyarn.nodemanager.local-dirs = /var/lib/hadoop-yarn/local","handlingStrategy":"validation","validationCode":"for (String dir : configuredDirs) {\n  java.nio.file.Path p = java.nio.file.Paths.get(dir);\n  if (java.nio.file.Files.exists(p) && !java.nio.file.Files.isDirectory(p)) {\n    throw new IllegalStateException(\"configured dir is a regular file: \" + dir);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate storage-dir config values against the filesystem during deployment","Use config management (Ansible/Chef) that creates directories, not just declares paths","Avoid symlinking storage paths to files"],"tags":["disk","filesystem","configuration","diskchecker","not-a-directory"],"backgroundTag":"not-a-directory","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}