{"record":{"id":"c1e71289e4835d02","repo":"apache/hadoop","slug":"file-file-does-not-exist","errorCode":null,"errorMessage":"File {file} does not exist.","messagePattern":"File (.+?) does not exist\\.","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ftp/FTPFileSystem.java","lineNumber":542,"sourceCode":"      boolean isDir = true;\n      int blockReplication = 1;\n      long blockSize = DEFAULT_BLOCK_SIZE; // Block Size not known.\n      long modTime = -1; // Modification time of root dir not known.\n      Path root = new Path(\"/\");\n      return new FileStatus(length, isDir, blockReplication, blockSize,\n          modTime, this.makeQualified(root));\n    }\n    String pathName = parentPath.toUri().getPath();\n    FTPFile[] ftpFiles = client.listFiles(pathName);\n    if (ftpFiles != null) {\n      for (FTPFile ftpFile : ftpFiles) {\n        if (ftpFile.getName().equals(file.getName())) { // file found in dir\n          fileStat = getFileStatus(ftpFile, parentPath);\n          break;\n        }\n      }\n      if (fileStat == null) {\n        throw new FileNotFoundException(\"File \" + file + \" does not exist.\");\n      }\n    } else {\n      throw new FileNotFoundException(\"File \" + file + \" does not exist.\");\n    }\n    return fileStat;\n  }\n\n  /**\n   * Convert the file information in FTPFile to a {@link FileStatus} object. *\n   * \n   * @param ftpFile\n   * @param parentPath\n   * @return FileStatus\n   */\n  private FileStatus getFileStatus(FTPFile ftpFile, Path parentPath) {\n    long length = ftpFile.getSize();\n    boolean isDir = ftpFile.isDirectory();\n    int blockReplication = 1;","sourceCodeStart":524,"sourceCodeEnd":560,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ftp/FTPFileSystem.java#L524-L560","documentation":"getFileStatus lists the parent directory via FTP LIST and matches entries by exact name; if the listing succeeds but no entry matches the path's final component, FileNotFoundException is thrown — the standard missing-file signal that open(), exists(), delete() and friends propagate.","triggerScenarios":"fs.getFileStatus/open/delete on a path whose final component does not exist in its parent; filename case mismatch (FTP names are case-sensitive); trailing spaces or characters lost when constructing paths.","commonSituations":"Stale paths after files were renamed/removed; glob results consumed after another process deleted the files; case-sensitivity mismatches between client and server platforms.","solutions":["Check fs.exists(path) (implemented as a getFileStatus that swallows exactly this exception) before access","Log the exact path string (with delimiters) when paths are built dynamically to expose whitespace/case issues","If a race deleted the file, decide explicitly between skipping the task and failing it"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (!fs.exists(path)) {\n  // skip or fail explicitly instead of letting open()/delete() throw\n  LOG.warn(\"Input missing: {}\", path);\n  return;\n}\nFSDataInputStream in = fs.open(path);","typeGuard":null,"tryCatchPattern":"try {\n  st = fs.getFileStatus(path);\n} catch (FileNotFoundException e) {\n  // expected for globs/optional inputs: skip or count-and-report\n  return null;\n}","preventionTips":["Use fs.exists() or catch FileNotFoundException as the normal missing-input path","Compare path strings byte-for-byte when names are built dynamically (case, spaces)"],"tags":["ftp","file-not-found","case-sensitivity"],"backgroundTag":"file-not-found","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}