{"record":{"id":"af47350da94cd649","repo":"apache/hadoop","slug":"file-does-not-exist-af4735","errorCode":null,"errorMessage":"File does not exist: ","messagePattern":"File does not exist: ","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java","lineNumber":1932,"sourceCode":"   * and it will get the resolved path's FileStatus object. It will not be\n   * represented as a symlink and isDirectory API returns true if the resolved\n   * path is a directory, false otherwise.\n   *\n   * @throws FileNotFoundException if the file does not exist.\n   */\n  @Override\n  public FileStatus getFileStatus(Path f) throws IOException {\n    statistics.incrementReadOps(1);\n    storageStatistics.incrementOpCounter(OpType.GET_FILE_STATUS);\n    Path absF = fixRelativePart(f);\n    return new FileSystemLinkResolver<FileStatus>() {\n      @Override\n      public FileStatus doCall(final Path p) throws IOException {\n        HdfsFileStatus fi = dfs.getFileInfo(getPathName(p));\n        if (fi != null) {\n          return fi.makeQualified(getUri(), p);\n        } else {\n          throw new FileNotFoundException(\"File does not exist: \" + p);\n        }\n      }\n      @Override\n      public FileStatus next(final FileSystem fs, final Path p)\n          throws IOException {\n        return fs.getFileStatus(p);\n      }\n    }.resolve(this, absF);\n  }\n\n  /**\n   * Synchronize client metadata state with Active NameNode.\n   * <p>\n   * In HA the client synchronizes its state with the Active NameNode\n   * in order to guarantee subsequent read consistency from Observer Nodes.\n   * @throws IOException\n   */\n  @Override","sourceCodeStart":1914,"sourceCodeEnd":1950,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java#L1914-L1950","documentation":"getFileStatus(Path) calls dfs.getFileInfo; the NameNode returns null when the path does not exist and the client throws FileNotFoundException with the offending path. This is the canonical HDFS 'stat failed' error and is the exception fs.exists() is built on top of.","triggerScenarios":"Calling getFileStatus (directly, or via fs.exists-adjacent code, FileInputFormat splits, Hive/Spark partition metadata checks) on a path absent from the namespace: deleted, never created, typo, or resolved against the wrong fs.defaultFS.","commonSituations":"Jobs reading partitions that were dropped by a retention job; wrong fs.defaultFS so absolute paths resolve to another cluster; paths with typos or missing scheme/authority; files deleted between a catalog update and the read.","solutions":["Call fs.exists(p) (or catch FileNotFoundException) when absence is a normal case and skip/log.","Fix the path construction: fully qualify with fs.makeQualified(p) or set fs.defaultFS correctly.","If racing with deletions, coordinate so readers finish before files are removed, or read from an HDFS snapshot path.","Verify the file was actually created upstream (check job output, _SUCCESS, distcp -update results)."],"exampleFix":"// before\nFileStatus st = fs.getFileStatus(path);\n\n// after\nFileStatus st;\ntry {\n  st = fs.getFileStatus(path);\n} catch (FileNotFoundException e) {\n  LOG.warn(\"Missing path, skipping: {}\", path);\n  return Optional.empty();\n}","handlingStrategy":"validation","validationCode":"if (fs.exists(p)) {\n  FileStatus st = fs.getFileStatus(p);\n} else {\n  // handle absence before calling\n}","typeGuard":null,"tryCatchPattern":"try {\n  FileStatus st = fs.getFileStatus(p);\n} catch (FileNotFoundException e) {\n  // normal-case absence: skip, default, or create the file\n}","preventionTips":["Use fs.exists() when absence is expected; use try-catch when the common case is that the file exists (avoids a second RPC).","Qualify paths explicitly (scheme+authority) in multi-cluster code.","Audit jobs that read paths derived from catalogs for races with retention/deletion jobs."],"tags":["hdfs","getfilestatus","file-not-found","distributed-filesystem"],"backgroundTag":"file-not-found","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}