{"record":{"id":"ff38d351686b2e19","repo":"apache/hadoop","slug":"path-ff38d3","errorCode":null,"errorMessage":"{path}","messagePattern":"\\{path\\}","errorType":"http","errorClass":"FileNotFoundException","httpStatus":404,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/FSImageLoader.java","lineNumber":566,"sourceCode":"    long id = INodeId.ROOT_INODE_ID;\n    for (int offset = 0, next; offset < path.length(); offset = next) {\n      next = path.indexOf('/', offset + 1);\n      if (next == -1) {\n        next = path.length();\n      }\n      if (offset + 1 > next) {\n        break;\n      }\n\n      final String component = path.substring(offset + 1, next);\n\n      if (component.isEmpty()) {\n        continue;\n      }\n\n      final long[] children = dirmap.get(id);\n      if (children == null) {\n        throw new FileNotFoundException(path);\n      }\n\n      boolean found = false;\n      for (long cid : children) {\n        FsImageProto.INodeSection.INode child = fromINodeId(cid);\n        if (component.equals(child.getName().toStringUtf8())) {\n          found = true;\n          id = child.getId();\n          break;\n        }\n      }\n      if (!found) {\n        throw new FileNotFoundException(path);\n      }\n    }\n    return id;\n  }\n","sourceCodeStart":548,"sourceCodeEnd":584,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/FSImageLoader.java#L548-L584","documentation":"While FSImageLoader walks a queried path component by component, it looks up the current inode id in dirmap (directory id → children array, built from the INODE_DIR section). A null result means that inode has no recorded children — it is a file, not a directory — so descending further is impossible and FileNotFoundException(path) is thrown. The oiv web server maps it to HTTP 404.","triggerScenarios":"Querying a path that continues below a file: /user/me/notes.txt/child via op=GETFILESTATUS or LISTSTATUS, including the trailing-slash form /user/me/notes.txt/ produced by naive path joining.","commonSituations":"Scripts that append '/' to every path uniformly; joining parent+child where the parent turns out to be a file; expecting symlink-style traversal semantics in a static fsimage.","solutions":["Remove the extra components or trailing slash after the file path.","Check the parent with op=GETFILESTATUS first and only descend when type is DIRECTORY.","Fix the path-construction logic in the calling script or client."],"exampleFix":"# before\ncurl 'http://localhost:5978/webhdfs/v1/user/me/notes.txt/?op=LISTSTATUS'\n# -> 404 (notes.txt is a file, cannot be listed into)\n\n# after\ncurl 'http://localhost:5978/webhdfs/v1/user/me/notes.txt?op=GETFILESTATUS'","handlingStrategy":"try-catch","validationCode":"// before descending, confirm the parent is a directory in the image\nString status = image.getFileStatus(parentPath);            // throws if absent\nif (!status.contains(\"\\\"type\\\":\\\"DIRECTORY\\\"\")) {           // JSON from GETFILESTATUS\n  throw new IllegalArgumentException(parentPath + \" is a file; cannot list into it\");\n}","typeGuard":"static boolean isDirectoryStatus(String fileStatusJson) {\n  return fileStatusJson != null && fileStatusJson.contains(\"\\\"type\\\":\\\"DIRECTORY\\\"\");\n}","tryCatchPattern":"try {\n  return image.getFileStatus(path);\n} catch (FileNotFoundException e) {\n  // 404 semantics: path absent, or a file used as an intermediate directory\n  // normalize the path (drop trailing '/') and GETFILESTATUS the parent to tell which\n  throw e;\n}","preventionTips":["Never append a trailing '/' blindly; only directories get one.","GETFILESTATUS the parent and check type == DIRECTORY before LISTSTATUS.","URL-decode path components before debugging — %2F changes the outcome."],"tags":["hdfs","offline-image-viewer","webhdfs","path-resolution","file-not-found"],"backgroundTag":"path-not-found","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}