{"record":{"id":"fb94f538443e8de8","repo":"apache/hadoop","slug":"file-already-exists","errorCode":null,"errorMessage":"File already exists.","messagePattern":"File already exists\\.","errorType":"exception","errorClass":"FileAlreadyExistsException","httpStatus":null,"severity":"error","filePath":"hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsDfsClient.java","lineNumber":1881,"sourceCode":"   * @param isMetadataIncompleteState Flag indicating if metadata is incomplete.\n   * @throws IOException If an I/O error occurs during the rename operation.\n   * @throws FileAlreadyExistsException If the destination file already exists.\n   */\n  private void handleRenameException(final String source,\n      final String destination, final String continuation,\n      final TracingContext tracingContext, final String sourceEtag,\n      final AbfsRestOperation op, boolean isMetadataIncompleteState,\n      AzureBlobFileSystemException e) throws IOException {\n    if (!op.hasResult()) {\n      throw e;\n    }\n\n    // ref: HADOOP-19393. Write permission checks can occur before validating\n    // rename operation's validity. If there is an existing destination path, it may be rejected\n    // with an authorization error. Catching and throwing FileAlreadyExistsException instead.\n    if (UNAUTHORIZED_BLOB_OVERWRITE.getErrorCode()\n        .equals(op.getResult().getStorageErrorCode())) {\n      throw new FileAlreadyExistsException(ERR_FILE_ALREADY_EXISTS);\n    }\n\n    // ref: HADOOP-18242. Rename failure occurring due to a rare case of\n    // tracking metadata being in incomplete state.\n    if (RENAME_DESTINATION_PARENT_PATH_NOT_FOUND.getErrorCode()\n        .equals(op.getResult().getStorageErrorCode())\n        && !isMetadataIncompleteState) {\n      ABFS_METADATA_INCOMPLETE_RENAME_FAILURE.info(\n          \"Rename Failure attempting to resolve tracking metadata state and retrying.\");\n      isMetadataIncompleteState = true;\n      String sourceEtagAfterFailure = sourceEtag;\n      if (isEmpty(sourceEtagAfterFailure)) {\n        // Doing a HEAD call resolves the incomplete metadata state and\n        // then we can retry the rename operation.\n        AbfsRestOperation sourceStatusOp = getPathStatus(source, false,\n            tracingContext, null);\n        // Extract the sourceEtag, using the status Op, and set it\n        // for future rename recovery.","sourceCodeStart":1863,"sourceCodeEnd":1899,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsDfsClient.java#L1863-L1899","documentation":"Error \"File already exists.\" thrown in apache/hadoop.","triggerScenarios":"create() without overwrite targets a path that already exists.","commonSituations":"See trigger scenarios.","solutions":["Use overwrite=true in create() if replacing the file is intended.","Choose a different target path or delete the existing file first."],"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"}