{"record":{"id":"49b0eaf116b010fd","repo":"apache/hadoop","slug":"path-does-not-exist","errorCode":null,"errorMessage":"Path {} does not exist","messagePattern":"Path (.+?) does not exist","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java","lineNumber":4358,"sourceCode":"    checkOperation(OperationCategory.READ);\n    readLock(RwLockMode.FS);\n    try {\n      checkOperation(NameNode.OperationCategory.READ);\n\n      // List all directories from the starting index until we've reached\n      // ls limit OR finished listing all srcs.\n      LinkedHashMap<Integer, HdfsPartialListing> listings =\n          Maps.newLinkedHashMap();\n      DirectoryListing lastListing = null;\n      int numEntries = 0;\n      for (; srcsIndex < srcs.length; srcsIndex++) {\n        String src = srcs[srcsIndex];\n        HdfsPartialListing listing;\n        try {\n          DirectoryListing dirListing =\n              getListingInt(dir, pc, src, indexStartAfter, needLocation);\n          if (dirListing == null) {\n            throw new FileNotFoundException(\"Path \" + src + \" does not exist\");\n          }\n          if (needLocation && isObserver()) {\n            for (HdfsFileStatus fs : dirListing.getPartialListing()) {\n              if (fs instanceof HdfsLocatedFileStatus) {\n                LocatedBlocks lbs = ((HdfsLocatedFileStatus) fs).getLocatedBlocks();\n                checkBlockLocationsWhenObserver(lbs, fs.toString());\n              }\n            }\n          }\n          listing = new HdfsPartialListing(\n              srcsIndex, Lists.newArrayList(dirListing.getPartialListing()));\n          numEntries += listing.getPartialListing().size();\n          lastListing = dirListing;\n        } catch (Exception e) {\n          if (e instanceof ObserverRetryOnActiveException) {\n            throw (ObserverRetryOnActiveException) e;\n          }\n          if (e instanceof AccessControlException) {","sourceCodeStart":4340,"sourceCodeEnd":4376,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java#L4340-L4376","documentation":"While assembling a batched listing, getListingInt returned null for one of the source paths, which in HDFS semantics means the path does not exist. FileNotFoundException names the offending src and aborts the whole batch request.","triggerScenarios":"A path in srcs was deleted or renamed between pagination calls (startAfter cursor) or never existed (typo, wrong mount); listing a path removed after the batch was assembled.","commonSituations":"Concurrent deletions during a long cursor-based listing; directory trees being restructured while enumerated; jobs listing dynamic directories that appear and disappear.","solutions":["Pre-validate each src with fs.exists (or util.exists) before submitting the batch","Handle FileNotFoundException per-batch by dropping the missing path and re-issuing the rest","Snapshot the path list once and tolerate stale entries rather than mixing live lookups"],"exampleFix":"// before\nString[] srcs = requestedPaths.toArray(new String[0]);\n\n// after\nList<String> srcs = new ArrayList<>();\nfor (String p : requestedPaths) {\n  if (fs.util().exists(new Path(p))) { srcs.add(p); }\n  else { LOG.debug(\"Skipping vanished path: \" + p); }\n}","handlingStrategy":"validation","validationCode":"List<String> valid = new ArrayList<>();\nfor (String s : srcs) {\n  if (fs.util().exists(new Path(s))) { valid.add(s); }\n}","typeGuard":null,"tryCatchPattern":"try {\n  listing = getBatchedListing(srcs, startAfter, needLocation);\n} catch (FileNotFoundException e) {\n  // drop the vanished path named in the message and re-issue the batch\n}","preventionTips":["Validate paths immediately before each listing batch, not once upfront","Tolerate churn: skip missing paths instead of failing the whole batch"],"tags":["hdfs","namenode","batched-listing","file-not-found"],"backgroundTag":"file-not-found","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}