apache/hadoop · error · IOException
Invalid file name: {} in {}
Error message
Invalid file name: {} in {} What it means
getFileHarStatus translates the qualified path into an archive-relative path with getPathInHar (HarFileSystem.java:356-373), which walks up the directory chain until it hits archivePath (the ...har directory fixed at initialize). If it reaches the filesystem root '/' without ever matching, it returns null and this IOException is thrown: the requested path is not under this archive's directory at all.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java:652
* index files. The permissions are not persisted
* while creating a hadoop archive.
* @param f the path in har filesystem
* @return filestatus.
* @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) {View on GitHub (pinned to 2add963021)
Solutions
- Make the path fully qualified and include the archive directory, e.g. har://hdfs-nn:8020/user/a/data.har/dir/file
- Verify the path starts with the same ...har directory as the URI the FileSystem was initialized with (fs.getWorkingDirectory() returns that archive root)
- List the archive root with fs.listStatus(archiveUri) to confirm the namespace you are addressing
Example fix
// before
FileSystem hfs = FileSystem.get(new URI("har://hdfs-nn:8020/user/a/data.har"), conf);
hfs.getFileStatus(new Path("har://hdfs-nn:8020/user/a/otherdir/file")); // not under data.har
// after
hfs.getFileStatus(new Path("har://hdfs-nn:8020/user/a/data.har/file")); Defensive patterns
Strategy: validation
Validate before calling
Path q = fs.makeQualified(path);
String archiveRoot = fs.getWorkingDirectory().toUri().getPath(); // top-level ...har directory
if (!q.toUri().getPath().startsWith(archiveRoot)) {
throw new IllegalArgumentException(path + " is not under archive " + archiveRoot);
} Try / catch
try {
fs.getFileStatus(path);
} catch (IOException e) {
if (e.getMessage() != null && e.getMessage().contains("Invalid file name")) {
// path is outside this archive's namespace: fix the configured archive directory
}
throw e;
} Prevention
- Always use fully qualified har:// paths that include the .har directory segment
- Derive member paths from the same archive URI used to create the FileSystem (fs.getWorkingDirectory())
- One HarFileSystem instance serves exactly one archive — never share it across archives
When it happens
Trigger: Calling getFileStatus, open, or exists (all routed through getFileHarStatus) with a path whose qualified form lacks the archive directory as an ancestor — e.g. omitting the /user/a/data.har segment, or using a path that belongs to a different archive or a sibling directory.
Common situations: Reusing one HarFileSystem instance with paths for another archive; dropping the .har directory segment from a stored path; code that qualifies relative paths against its own working directory before calling the har filesystem.
Related errors
- query component in Path not supported {}
- URI: {} is an invalid Har URI. Expecting har://<scheme>-<hos
- File: {} does not exist in {}
- {} : not a file in {}
- Har: create not allowed.
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/b1dd036ef3603fc2.
Report an issue: GitHub.