{"record":{"id":"4ac3b1ea6bb65b3d","repo":"apache/hadoop","slug":"no-such-file-or-directory-4ac3b1","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/OBSObjectBucketUtils.java","lineNumber":813,"sourceCode":"                newKey, e);\n          }\n        }\n      }\n    }\n\n    try {\n      boolean isEmpty = OBSCommonUtils.innerIsFolderEmpty(owner, key);\n      LOG.debug(\"Is dir ({}) empty? {}\", path, isEmpty);\n      return new OBSFileStatus(path, owner.getUsername());\n    } catch (ObsException e) {\n      if (e.getResponseCode() != OBSCommonUtils.NOT_FOUND_CODE) {\n        throw OBSCommonUtils.translateException(\"getFileStatus\", key,\n            e);\n      }\n    }\n\n    LOG.debug(\"Not Found: {}\", path);\n    throw new FileNotFoundException(\"No such file or directory: \" + path);\n  }\n\n  static ContentSummary getDirectoryContentSummary(final OBSFileSystem owner,\n      final String key) throws IOException {\n    String newKey = key;\n    newKey = OBSCommonUtils.maybeAddTrailingSlash(newKey);\n    long[] summary = {0, 0, 1};\n    LOG.debug(\"Summary key {}\", newKey);\n    ListObjectsRequest request = new ListObjectsRequest();\n    request.setBucketName(owner.getBucket());\n    request.setPrefix(newKey);\n    Set<String> directories = new TreeSet<>();\n    request.setMaxKeys(owner.getMaxKeys());\n    ObjectListing objects = OBSCommonUtils.listObjects(owner, request);\n    while (true) {\n      if (!objects.getCommonPrefixes().isEmpty() || !objects.getObjects()\n          .isEmpty()) {\n        if (LOG.isDebugEnabled()) {","sourceCodeStart":795,"sourceCodeEnd":831,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-cloud-storage-project/hadoop-huaweicloud/src/main/java/org/apache/hadoop/fs/obs/OBSObjectBucketUtils.java#L795-L831","documentation":"In the object-bucket getFileStatus, a path is probed as an object and as a directory; when the underlying ObsException carries response code 404 and the folder is empty-check also misses, the code throws FileNotFoundException('No such file or directory: <path>'). This matches the Hadoop contract that getFileStatus fails with FNFE for absent paths.","triggerScenarios":"fs.open or fs.getFileStatus on a path never written, deleted by another client, or whose parent directory has no marker object; also paths with stray trailing slashes or double slashes that map to a different object key.","commonSituations":"Race between a writer and a reader on OBS; wrong bucket or prefix in the job configuration; cleanup removed data before a late task read it; a straggler task reading a source already renamed away.","solutions":["Check fs.exists(path) or catch FileNotFoundException when absence is an expected outcome","Verify the path string, bucket, and prefix against an actual listing (fs.listStatus on the parent)","For writer/reader races, wait on a completion marker such as _SUCCESS instead of retrying blindly"],"exampleFix":"// before\nFSDataInputStream in = fs.open(new Path(\"/data/part-0\"));\n\n// after\nPath p = new Path(\"/data/part-0\");\nif (!fs.exists(p)) {\n  throw new FileNotFoundException(\"Input missing: \" + p);\n}\nFSDataInputStream in = fs.open(p);","handlingStrategy":"try-catch","validationCode":"if (!fs.exists(p)) {\n  // handle absence before calling open/getFileStatus\n  return Optional.empty();\n}","typeGuard":null,"tryCatchPattern":"try {\n  return Optional.of(fs.getFileStatus(p));\n} catch (FileNotFoundException e) {\n  return Optional.empty(); // absence is a normal outcome for lookups\n}","preventionTips":["Wrap lookups in Optional-style FNFE handling instead of letting it escape","Wait on a _SUCCESS marker before reading job output","Validate bucket and prefix configuration with a listing before processing"],"tags":["hadoop","obs","file-not-found","getfilestatus","object-storage"],"backgroundTag":"file-not-found","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}