{"record":{"id":"3880b665ecbb6e22","repo":"apache/hadoop","slug":"rename-destination-already-exists","errorCode":null,"errorMessage":"rename destination {} already exists","messagePattern":"rename destination (.+?) already exists","errorType":"exception","errorClass":"FileAlreadyExistsException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirRenameOp.java","lineNumber":583,"sourceCode":"    }\n  }\n\n  private static void validateOverwrite(\n      String src, String dst, boolean overwrite, INode srcInode, INode dstInode)\n      throws IOException {\n    String error;// It's OK to rename a file to a symlink and vice versa\n    if (dstInode.isDirectory() != srcInode.isDirectory()) {\n      error = \"Source \" + src + \" and destination \" + dst\n          + \" must both be directories\";\n      NameNode.stateChangeLog.warn(\"DIR* FSDirectory.unprotectedRenameTo: \"\n          + error);\n      throw new IOException(error);\n    }\n    if (!overwrite) { // If destination exists, overwrite flag must be true\n      error = \"rename destination \" + dst + \" already exists\";\n      NameNode.stateChangeLog.warn(\"DIR* FSDirectory.unprotectedRenameTo: \"\n          + error);\n      throw new FileAlreadyExistsException(error);\n    }\n    if (dstInode.isDirectory()) {\n      final ReadOnlyList<INode> children = dstInode.asDirectory()\n          .getChildrenList(Snapshot.CURRENT_STATE_ID);\n      if (!children.isEmpty()) {\n        error = \"rename destination directory is not empty: \" + dst;\n        NameNode.stateChangeLog.warn(\"DIR* FSDirectory.unprotectedRenameTo: \"\n            + error);\n        throw new IOException(error);\n      }\n    }\n  }\n\n  private static void validateRenameSource(FSDirectory fsd,\n      INodesInPath srcIIP, List<INodeDirectory> snapshottableDirs)\n      throws IOException {\n    String error;\n    final INode srcInode = srcIIP.getLastINode();","sourceCodeStart":565,"sourceCodeEnd":601,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirRenameOp.java#L565-L601","documentation":"Error \"rename destination {} already exists\" thrown in apache/hadoop.","triggerScenarios":"Renaming a path to a destination that already exists and no overwrite option was given.","commonSituations":"See trigger scenarios.","solutions":["Remove or rename the existing destination path first.","Choose a different, non-existing destination name."],"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"}