{"record":{"id":"396dcc90399a482e","repo":"apache/hadoop","slug":"rename-source-src-not-found","errorCode":null,"errorMessage":"rename source ${src} not found.","messagePattern":"rename source (.+?) not found\\.","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java","lineNumber":1675,"sourceCode":"   * </p>\n   *\n   * @param src path to be renamed\n   * @param dst new path after rename\n   * @param options rename options.\n   * @throws FileNotFoundException src path does not exist, or the parent\n   * path of dst does not exist.\n   * @throws FileAlreadyExistsException dest path exists and is a file\n   * @throws ParentNotDirectoryException if the parent path of dest is not\n   * a directory\n   * @throws IOException on failure\n   */\n  @Deprecated\n  protected void rename(final Path src, final Path dst,\n      final Rename... options) throws IOException {\n    // Default implementation\n    final FileStatus srcStatus = getFileLinkStatus(src);\n    if (srcStatus == null) {\n      throw new FileNotFoundException(\"rename source \" + src + \" not found.\");\n    }\n\n    boolean overwrite = false;\n    if (null != options) {\n      for (Rename option : options) {\n        if (option == Rename.OVERWRITE) {\n          overwrite = true;\n        }\n      }\n    }\n\n    FileStatus dstStatus;\n    try {\n      dstStatus = getFileLinkStatus(dst);\n    } catch (IOException e) {\n      dstStatus = null;\n    }\n    if (dstStatus != null) {","sourceCodeStart":1657,"sourceCodeEnd":1693,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java#L1657-L1693","documentation":"The deprecated options-aware rename(src, dst, Rename...) default begins with getFileLinkStatus(src); on implementations that return null for absent paths (rather than throwing), it throws FileNotFoundException('rename source src not found.'). This is the API's explicit not-found signal for renames.","triggerScenarios":"Invoking the options-based rename (directly or via adapters that forward to it) after the source was deleted, mistyped, or lives under a different filesystem authority.","commonSituations":"Concurrent jobs consuming/moving the same inputs (source gone by the time of the move); source paths built from wrong config; custom FileSystem whose getFileLinkStatus returns null instead of throwing.","solutions":["Check fs.exists(src) immediately before the rename and skip/log when absent","Fix the source path construction (config values, path qualification, authority)","If you implement a FileSystem, throw FileNotFoundException from getFileLinkStatus for missing paths"],"exampleFix":"// before\nfs.rename(src, dst, Rename.OVERWRITE);\n\n// after\nif (!fs.exists(src)) {\n  LOG.warn(\"rename skipped, source gone: {}\", src);\n} else {\n  fs.rename(src, dst, Rename.OVERWRITE);\n}","handlingStrategy":"validation","validationCode":"if (!fs.exists(src)) {\n  LOG.warn(\"rename skipped, source gone: {}\", src);\n  return;\n}\nfs.rename(src, dst, Rename.OVERWRITE);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Re-stat inputs at the moment of use, not long before","Make rename consumers idempotent so a missing source is benign","If implementing a FileSystem, throw (never return null) from getFileLinkStatus"],"tags":["hadoop","filesystem","rename","file-not-found"],"backgroundTag":"source-not-found","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}