apache/hadoop · error · FileNotFoundException
File: {} does not exist in {}
Error message
File: {} does not exist in {} What it means
The path translated into archive-relative form, but metadata.archive.get(harPath) — the in-memory index parsed from _masterindex/_index — has no entry for it. Archive membership is frozen when `hadoop archive` ran; anything not in the index does not exist in the har namespace, even if a file with that name exists in the underlying directory.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java:656
* @throws IOException raised on errors performing I/O.
*/
@Override
public FileStatus getFileStatus(Path f) throws IOException {
HarStatus hstatus = getFileHarStatus(f);
return toFileStatus(hstatus);
}
private HarStatus getFileHarStatus(Path f) throws IOException {
// get the fs DataInputStream for the underlying file
// look up the index.
Path p = makeQualified(f);
Path harPath = getPathInHar(p);
if (harPath == null) {
throw new IOException("Invalid file name: " + f + " in " + uri);
}
HarStatus hstatus = metadata.archive.get(harPath);
if (hstatus == null) {
throw new FileNotFoundException("File: " + f + " does not exist in " + uri);
}
return hstatus;
}
@Override
public void msync() throws IOException, UnsupportedOperationException {
fs.msync();
}
/**
* @return null since no checksum algorithm is implemented.
*/
@Override
public FileChecksum getFileChecksum(Path f, long length) {
return null;
}
/**View on GitHub (pinned to 2add963021)
Solutions
- List the parent directory with fs.listStatus(parent) to see the exact names present in the archive index
- If files were added after archiving, rebuild with `hadoop archive -archiveName data.har -p <srcDir> <destDir>`
- Verify the archive-path portion of the URI points at the intended .har
Example fix
// before
fs.open(new Path("har://hdfs-nn:8020/a/data.har/utls/report.csv")); // typo: 'utls'
// after
for (FileStatus s : fs.listStatus(new Path("har://hdfs-nn:8020/a/data.har/utils"))) {
System.out.println(s.getPath()); // use the exact listed name
} Defensive patterns
Strategy: try-catch
Validate before calling
Path parent = path.getParent();
boolean present = false;
for (FileStatus s : fs.listStatus(parent)) {
if (s.getPath().getName().equals(path.getName())) { present = true; break; }
}
if (!present) { /* handle missing member */ } Try / catch
try {
fs.getFileStatus(p);
} catch (FileNotFoundException e) {
// member not in the archive index: treat as absent, log with archive URI
} Prevention
- Treat FileNotFoundException as the supported 'does not exist' signal on har paths
- Derive member names from listStatus output instead of hard-coded strings
- Rebuild archives whenever the source tree changes; never assume source and archive stay in sync
When it happens
Trigger: getFileStatus/open/exists on a name that is not an index entry: a typo in a segment, the wrong sub-directory, a file created in the source tree after the archive was built, or assuming membership because the file exists on the underlying filesystem.
Common situations: Stale archive versus a source directory that kept changing; path spelling/case mistakes; consumers pointed at the wrong .har version or wrong path-inside-archive.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- File {} not found in {}
- {} : not a file in {}
- key + ": No such file or directory."
- No such file or directory '{}'
- '{}' is a directory
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/156ca0a48b63bad0.
Report an issue: GitHub.