{"record":{"id":"54c8ba26f856614f","repo":"apache/hadoop","slug":"cannot-rename-a-directory-to-a-subdirectory-of-its","errorCode":null,"errorMessage":"cannot rename a directory to a subdirectory of itself ","messagePattern":"cannot rename a directory to a subdirectory of itself ","errorType":"exception","errorClass":"RenameFailedException","httpStatus":null,"severity":"error","filePath":"hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/impl/RenameOperation.java","lineNumber":364,"sourceCode":"\n  /**\n   * Execute a full recursive rename.\n   * There is a special handling of directly markers here -only leaf markers\n   * are copied. This reduces incompatibility \"regions\" across versions.\n   * @throws IOException failure\n   */\n  protected void recursiveDirectoryRename() throws IOException {\n    final StoreContext storeContext = getStoreContext();\n\n    LOG.debug(\"rename: renaming directory {} to {}\", sourcePath, destPath);\n\n    // This is a directory-to-directory copy\n    String dstKey = maybeAddTrailingSlash(destKey);\n    String srcKey = maybeAddTrailingSlash(sourceKey);\n\n    // Verify dest is not a child of the source directory\n    if (dstKey.startsWith(srcKey)) {\n      throw new RenameFailedException(srcKey, dstKey,\n          \"cannot rename a directory to a subdirectory of itself \");\n    }\n    // start the async dir cleanup\n    final CompletableFuture<Long> abortUploads;\n    if (dirOperationsPurgeUploads) {\n      final String key = srcKey;\n      LOG.debug(\"All uploads under {} will be deleted\", key);\n      abortUploads = submit(getStoreContext().getExecutor(), () ->\n          callbacks.abortMultipartUploadsUnderPrefix(key));\n    } else {\n      abortUploads = null;\n    }\n\n    if (destStatus != null\n        && destStatus.isEmptyDirectory() == Tristate.TRUE) {\n      // delete unnecessary fake directory at the destination.\n\n      LOG.debug(\"Deleting fake directory marker at destination {}\",","sourceCodeStart":346,"sourceCodeEnd":382,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/impl/RenameOperation.java#L346-L382","documentation":"Error \"cannot rename a directory to a subdirectory of itself \" thrown in apache/hadoop.","triggerScenarios":"Thrown at hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/impl/RenameOperation.java:364 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Choose a destination that is not inside the source directory."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}