apache/hadoop · error · FileNotFoundException

rename source ${src} not found.

Error message

rename source ${src} not found.

What it means

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.

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java:1675

   * </p>
   *
   * @param src path to be renamed
   * @param dst new path after rename
   * @param options rename options.
   * @throws FileNotFoundException src path does not exist, or the parent
   * path of dst does not exist.
   * @throws FileAlreadyExistsException dest path exists and is a file
   * @throws ParentNotDirectoryException if the parent path of dest is not
   * a directory
   * @throws IOException on failure
   */
  @Deprecated
  protected void rename(final Path src, final Path dst,
      final Rename... options) throws IOException {
    // Default implementation
    final FileStatus srcStatus = getFileLinkStatus(src);
    if (srcStatus == null) {
      throw new FileNotFoundException("rename source " + src + " not found.");
    }

    boolean overwrite = false;
    if (null != options) {
      for (Rename option : options) {
        if (option == Rename.OVERWRITE) {
          overwrite = true;
        }
      }
    }

    FileStatus dstStatus;
    try {
      dstStatus = getFileLinkStatus(dst);
    } catch (IOException e) {
      dstStatus = null;
    }
    if (dstStatus != null) {

View on GitHub (pinned to 2add963021)

Solutions

  1. Check fs.exists(src) immediately before the rename and skip/log when absent
  2. Fix the source path construction (config values, path qualification, authority)
  3. If you implement a FileSystem, throw FileNotFoundException from getFileLinkStatus for missing paths

Example fix

// before
fs.rename(src, dst, Rename.OVERWRITE);

// after
if (!fs.exists(src)) {
  LOG.warn("rename skipped, source gone: {}", src);
} else {
  fs.rename(src, dst, Rename.OVERWRITE);
}
Defensive patterns

Strategy: validation

Validate before calling

if (!fs.exists(src)) {
  LOG.warn("rename skipped, source gone: {}", src);
  return;
}
fs.rename(src, dst, Rename.OVERWRITE);

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/396dcc90399a482e. Report an issue: GitHub.