{"record":{"id":"88ba83f9b09d65eb","repo":"apache/hadoop","slug":"source-path-src-does-not-exist","errorCode":null,"errorMessage":"Source path {src} does not exist","messagePattern":"Source path (.+?) 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":677,"sourceCode":"  /**\n   * Convenience method, so that we don't open a new connection when using this\n   * method from within another method. Otherwise every API invocation incurs\n   * the overhead of opening/closing a TCP connection.\n   * \n   * @param client\n   * @param src\n   * @param dst\n   * @return\n   * @throws IOException\n   */\n  @SuppressWarnings(\"deprecation\")\n  private boolean rename(FTPClient client, Path src, Path dst)\n      throws IOException {\n    Path workDir = new Path(client.printWorkingDirectory());\n    Path absoluteSrc = makeAbsolute(workDir, src);\n    Path absoluteDst = makeAbsolute(workDir, dst);\n    if (!exists(client, absoluteSrc)) {\n      throw new FileNotFoundException(\"Source path \" + src + \" does not exist\");\n    }\n    if (isDirectory(absoluteDst)) {\n      // destination is a directory: rename goes underneath it with the\n      // source name\n      absoluteDst = new Path(absoluteDst, absoluteSrc.getName());\n    }\n    if (exists(client, absoluteDst)) {\n      throw new FileAlreadyExistsException(\"Destination path \" + dst\n          + \" already exists\");\n    }\n    URI parentSrc = absoluteSrc.getParent().toUri();\n    URI parentDst = absoluteDst.getParent().toUri();\n    if (isParentOf(absoluteSrc, absoluteDst)) {\n      throw new IOException(\"Cannot rename \" + absoluteSrc + \" under itself\"\n      + \" : \"+ absoluteDst);\n    }\n\n    if (!parentSrc.toString().equals(parentDst.toString())) {","sourceCodeStart":659,"sourceCodeEnd":695,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ftp/FTPFileSystem.java#L659-L695","documentation":"Before issuing the FTP RNFR/RNTO pair, FTPFileSystem.rename resolves src against the server's working directory and probes existence; if the source is absent it throws java.io.FileNotFoundException(\"Source path <src> does not exist\"). Note the message echoes the user-supplied (possibly relative) path, not the absolute path that was actually checked.","triggerScenarios":"rename(src, dst) where src does not exist on the FTP server; a relative src resolved against the FTP login directory rather than the client's expected root; the entry was deleted or moved between an exists() check and the rename; case mismatch on a case-sensitive server.","commonSituations":"Paths built from a different root than the FTP home directory (relative vs fully-qualified ftp:// paths); files consumed and renamed concurrently by another process; code ported from LocalFileSystem where names happened to be case-insensitive.","solutions":["Call fs.exists(src) immediately before rename and handle the missing case explicitly","Use fully-qualified paths (fs.makeQualified(src)) so resolution against the FTP login directory cannot surprise you","List the parent (fs.listStatus(src.getParent())) to confirm exact spelling and case of the entry","If another process moves files, add coordination (done-marker, lease directory) so rename races cannot happen"],"exampleFix":"// before\nfs.rename(src, dst);  // FileNotFoundException: Source path ... does not exist\n\n// after\nif (!fs.exists(src.makeQualified(fs))) {\n  throw new FileNotFoundException(\"Nothing to rename at \" + src + \"; check spelling/case\");\n}\nfs.rename(src, dst);","handlingStrategy":"validation","validationCode":"// before rename\nif (!fs.exists(src.makeQualified(fs))) {\n  // source genuinely absent: re-list parent, alert, or skip\n  LOG.warn(\"rename source missing: {}\", src);\n  return;\n}\nfs.rename(src, dst);","typeGuard":null,"tryCatchPattern":"catch FileNotFoundException from rename and distinguish it from FTP session errors (FTPException) — only the former means the path is absent.","preventionTips":["Always fully-qualify paths before FTP operations","Check exists() immediately before rename to shrink the race window","Verify path case against a directory listing on case-sensitive servers"],"tags":["ftp","hadoop","rename","file-not-found"],"backgroundTag":"file-not-found","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}