{"record":{"id":"467f5bfe5bf9e841","repo":"apache/hadoop","slug":"file-not-found-in","errorCode":null,"errorMessage":"File {} not found in {}","messagePattern":"File (.+?) not found in (.+?)","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java","lineNumber":795,"sourceCode":"    throw new IOException(\"Har: delete not allowed\");\n  }\n\n  /**\n   * liststatus returns the children of a directory \n   * after looking up the index files.\n   */\n  @Override\n  public FileStatus[] listStatus(Path f) throws IOException {\n    //need to see if the file is an index in file\n    //get the filestatus of the archive directory\n    // we will create fake filestatuses to return\n    // to the client\n    List<FileStatus> statuses = new ArrayList<FileStatus>();\n    Path tmpPath = makeQualified(f);\n    Path harPath = getPathInHar(tmpPath);\n    HarStatus hstatus = metadata.archive.get(harPath);\n    if (hstatus == null) {\n      throw new FileNotFoundException(\"File \" + f + \" not found in \" + archivePath);\n    }\n    if (hstatus.isDir()) {\n      fileStatusesInIndex(hstatus, statuses);\n    } else {\n      statuses.add(toFileStatus(hstatus));\n    }\n    \n    return statuses.toArray(new FileStatus[statuses.size()]);\n  }\n  \n  /**\n   * return the top level archive path.\n   */\n  @Override\n  public Path getHomeDirectory() {\n    return new Path(uri.toString());\n  }\n","sourceCodeStart":777,"sourceCodeEnd":813,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java#L777-L813","documentation":"listStatus looks the path up directly in the archive index (metadata.archive.get(harPath) at HarFileSystem.java:793); when no entry exists it throws FileNotFoundException. Unlike getFileStatus, there is no separate invalid-name check — any path that does not resolve to an index entry (wrong name, or a path the archive does not contain) lands here.","triggerScenarios":"fs.listStatus(p) where p is not an index entry: a misspelled member or directory, a path 'inside' the archive directory that was never archived, or a path outside this archive's namespace whose har-relative lookup misses.","commonSituations":"Directory-listing UIs and globbing over archived datasets; consumers listing a sub-directory that exists in the source tree but was added after the archive was built; typos in stored path templates.","solutions":["List the parent directory (or the archive root) to see which entries actually exist in the index","If the directory was added after archiving, rebuild with `hadoop archive`","Confirm the path is under the same .har directory as the filesystem's own URI"],"exampleFix":"// before\nfs.listStatus(new Path(\"har://hdfs-nn:8020/a/data.har/reportts\")); // typo\n\n// after\nfs.listStatus(new Path(\"har://hdfs-nn:8020/a/data.har\")); // list archive root, then drill down by exact names","handlingStrategy":"try-catch","validationCode":"Path parent = p.getParent();\ntry {\n  FileStatus[] children = fs.listStatus(parent);\n  boolean exists = java.util.Arrays.stream(children).anyMatch(s -> s.getPath().getName().equals(p.getName()));\n} catch (FileNotFoundException e) { /* parent itself is not in the index */ }","typeGuard":null,"tryCatchPattern":"try {\n  FileStatus[] st = fs.listStatus(p);\n} catch (FileNotFoundException e) {\n  // no index entry for p: list the parent or the archive root to discover real names\n}","preventionTips":["Treat FileNotFoundException from listStatus as the supported not-found signal","Discover member names by listing top-down from the archive root instead of guessing","Rebuild archives when source directories change so listings match expectations"],"tags":["hadoop","har-filesystem","file-not-found","liststatus","archive-index"],"backgroundTag":"file-not-found","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}