{"record":{"id":"ed245de168fc965e","repo":"apache/hadoop","slug":"no-such-file-or-directory-ed245d","errorCode":null,"errorMessage":"No such file or directory: {}","messagePattern":"No such file or directory: (.+?)","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"hadoop-cloud-storage-project/hadoop-huaweicloud/src/main/java/org/apache/hadoop/fs/obs/OBSPosixBucketUtils.java","lineNumber":278,"sourceCode":"          \"renameFile(\" + src + \", \" + dst + \")\", src, e);\n    }\n  }\n\n  static void innerFsRenameFile(final OBSFileSystem owner,\n      final String srcKey,\n      final String dstKey) throws IOException {\n    LOG.debug(\"RenameFile path {} to {}\", srcKey, dstKey);\n\n    try {\n      final RenameRequest renameObjectRequest = new RenameRequest();\n      renameObjectRequest.setBucketName(owner.getBucket());\n      renameObjectRequest.setObjectKey(srcKey);\n      renameObjectRequest.setNewObjectKey(dstKey);\n      owner.getObsClient().renameFile(renameObjectRequest);\n      owner.getSchemeStatistics().incrementWriteOps(1);\n    } catch (ObsException e) {\n      if (e.getResponseCode() == OBSCommonUtils.NOT_FOUND_CODE) {\n        throw new FileNotFoundException(\n            \"No such file or directory: \" + srcKey);\n      }\n      if (e.getResponseCode() == OBSCommonUtils.CONFLICT_CODE) {\n        throw new FileConflictException(\n            \"File conflicts during rename, \" + e.getResponseStatus());\n      }\n      throw OBSCommonUtils.translateException(\n          \"renameFile(\" + srcKey + \", \" + dstKey + \")\", srcKey, e);\n    }\n  }\n\n  /**\n   * Used to rename a source object to a destination object which is not existed\n   * before rename.\n   *\n   * @param owner  OBS File System instance\n   * @param srcKey source object key\n   * @param dstKey destination object key","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-cloud-storage-project/hadoop-huaweicloud/src/main/java/org/apache/hadoop/fs/obs/OBSPosixBucketUtils.java#L260-L296","documentation":"renameFile sends the OBS POSIX RenameRequest; an ObsException with response code 404 means the source key does not exist, and it is surfaced as FileNotFoundException('No such file or directory: <srcKey>'). Note the message carries the object key, not the Path.","triggerScenarios":"Renaming an object already moved or deleted by another client or task attempt; a source path typo or an unqualified path that resolved to a different key; the visibility window after a concurrent create.","commonSituations":"Idempotent job retry where the first attempt already moved the source; concurrent tasks racing on the same input; speculative executions of the same task.","solutions":["Treat FileNotFoundException on rename as 'already moved' when the destination exists: verify with getFileStatus(dst) and report success","Guard with an existence check immediately before the rename where races are possible","Log the failing key and compare it against a listing of the parent prefix to catch path-construction bugs"],"exampleFix":"// before\nfs.rename(src, dst);\n\n// after\ntry {\n  fs.rename(src, dst);\n} catch (FileNotFoundException e) {\n  if (!fs.exists(dst)) {\n    throw e; // genuinely missing source\n  }\n  // moved by a concurrent attempt: treat as success\n}","handlingStrategy":"try-catch","validationCode":"if (!fs.exists(src)) {\n  if (fs.exists(dst)) {\n    // already moved by a concurrent attempt: treat as success\n  } else {\n    throw new FileNotFoundException(\"Missing source: \" + src);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  fs.rename(src, dst);\n} catch (FileNotFoundException e) {\n  if (fs.exists(dst)) {\n    // source already moved: idempotent success\n  } else {\n    throw e; // genuinely missing source\n  }\n}","preventionTips":["Treat FNFE on rename as a possible concurrent move, not only as corruption","Verify both endpoints when tasks may be speculative or retried","Log object keys on failure so races can be distinguished from path bugs"],"tags":["hadoop","obs","posix","rename","file-not-found"],"backgroundTag":"file-not-found","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}