apache/hadoop · error · FileNotFoundException
%s not found: %s
Error message
%s not found: %s
What it means
GoogleHadoopFileSystem.getFileStatus throws FileNotFoundException("File|Directory not found: <path>") when getGcsFs().getFileInfo(gcsPath) reports the item as non-existent. This follows standard Hadoop FileSystem semantics: stat on a missing path raises FileNotFoundException, prefixed with whether the path would have been a directory or file.
Source
Thrown at hadoop-cloud-storage-project/hadoop-gcp/src/main/java/org/apache/hadoop/fs/gs/GoogleHadoopFileSystem.java:654
return true;
},
String.format("mkdirs(%s)", hadoopPath));
}
@Override
public FileStatus getFileStatus(final Path path) throws IOException {
return runOperation(
GcsStatistics.INVOCATION_GET_FILE_STATUS,
() -> {
checkArgument(path != null, "path must not be null");
checkOpen();
URI gcsPath = getGcsPath(path);
FileInfo fileInfo = getGcsFs().getFileInfo(gcsPath);
if (!fileInfo.exists()) {
throw new FileNotFoundException(
String.format(
"%s not found: %s", fileInfo.isDirectory() ? "Directory" : "File", path));
}
String userName = getUgiUserName();
return getFileStatus(fileInfo, userName);
},
String.format("getFileStatus(%s)", path));
}
/**
* Returns home directory of the current user.
*
* <p>Note: This directory is only used for Hadoop purposes. It is not the same as a user's OS
* home directory.
*/
@Override
public Path getHomeDirectory() {
Path result = new Path(fsRoot, "user/" + System.getProperty("user.name"));View on GitHub (pinned to 2add963021)
Solutions
- Use fs.exists(path) when you only need existence.
- Catch FileNotFoundException as the idiomatic 'missing' signal rather than pre-checking in concurrent environments.
- Verify the path/bucket prefix construction if the object is expected to exist.
Example fix
// before
FileStatus st = fs.getFileStatus(new Path("gs://bucket/missing")); // FileNotFoundException
// after
if (fs.exists(path)) {
FileStatus st = fs.getFileStatus(path);
} else {
// handle missing path
} Defensive patterns
Strategy: try-catch
Validate before calling
if (fs.exists(path)) {
FileStatus st = fs.getFileStatus(path);
} else {
// handle missing path without exception
} Try / catch
try {
FileStatus st = fs.getFileStatus(path);
} catch (FileNotFoundException e) {
// idiomatic Hadoop 'missing' signal - do not wrap in generic error handling
} Prevention
- Use fs.exists() for pure existence checks; reserve getFileStatus for when you need metadata.
- In concurrent environments, catch FileNotFoundException instead of pre-checking to avoid TOCTOU.
When it happens
Trigger: fs.getFileStatus(new Path("gs://b/missing")) for any absent object/directory; also TOCTOU where the object is deleted between a prior check and this call.
Common situations: Using getFileStatus for existence checks instead of fs.exists(); races with concurrent deleting/renaming jobs; wrong bucket or root prefix in constructed paths; missing GCS directory placeholders for 'empty' directories.
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
- Cannot overwrite an existing file: %s
- Cannot rename because path does not exist: %s
- Can not create '%s' file, because parent folder does not exi
- GoogleHadoopFileSystem has been closed or not initialized.
- Parent directory doesn't exist: {}
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/0f7bc2d3deb890b6.
Report an issue: GitHub.