apache/hadoop · error · FileNotFoundException
"File/Directory does not exist: " + iip.getPath()
Error message
"File/Directory does not exist: " + iip.getPath()
What it means
getStoragePolicy resolves the path (DirOp.READ_LINK), checks READ permission, then requires a non-null last INode; nothing at the path throws FileNotFoundException with the resolved path. This is the standard missing-path guard for the storage-policy query used by 'hdfs storagepolicies -getStoragePolicy'.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirAttrOp.java:213
return fsd.getAuditFileInfo(iip);
}
static BlockStoragePolicy[] getStoragePolicies(BlockManager bm)
throws IOException {
return bm.getStoragePolicies();
}
static BlockStoragePolicy getStoragePolicy(FSDirectory fsd,
FSPermissionChecker pc, BlockManager bm, String path) throws IOException {
fsd.readLock();
try {
final INodesInPath iip = fsd.resolvePath(pc, path, DirOp.READ_LINK);
if (fsd.isPermissionEnabled()) {
fsd.checkPathAccess(pc, iip, FsAction.READ);
}
INode inode = iip.getLastINode();
if (inode == null) {
throw new FileNotFoundException("File/Directory does not exist: "
+ iip.getPath());
}
return bm.getStoragePolicy(inode.getStoragePolicyID());
} finally {
fsd.readUnlock();
}
}
static long getPreferredBlockSize(FSDirectory fsd, FSPermissionChecker pc,
String src) throws IOException {
fsd.readLock();
try {
final INodesInPath iip = fsd.resolvePath(pc, src, DirOp.READ_LINK);
return INodeFile.valueOf(iip.getLastINode(), iip.getPath())
.getPreferredBlockSize();
} finally {
fsd.readUnlock();
}View on GitHub (pinned to 2add963021)
Solutions
- Guard with fs.exists(path) and accept it is racy - still handle FileNotFoundException in the call.
- For audit/reporting tools, catch FileNotFoundException per path and report/skip rather than abort the run.
- Fix the manifest or upstream job if the entries were expected to exist.
Example fix
// before
BlockStoragePolicy p = ((DistributedFileSystem) fs).getStoragePolicy(path);
// after
if (!fs.exists(path)) {
LOG.warn("skip policy check, path missing: {}", path);
return;
}
BlockStoragePolicy p = ((DistributedFileSystem) fs).getStoragePolicy(path); Defensive patterns
Strategy: validation
Validate before calling
if (!fs.exists(path)) {
LOG.warn("cannot query storage policy, path missing: {}", path);
return null;
}
return ((DistributedFileSystem) fs).getStoragePolicy(path); Try / catch
try {
return dfs.getStoragePolicy(path);
} catch (FileNotFoundException e) {
return null; // audit tools: record and continue with the next path
} Prevention
- Skip-or-report per path in batch audit tools rather than failing the run.
- Regenerate manifests from live listings instead of stale snapshots.
When it happens
Trigger: DistributedFileSystem.getStoragePolicy(path) on a path that does not exist: deleted between listing and lookup, typo, wrong partition/mount path, or a manifest entry that was never created.
Common situations: Policy audit scripts iterating stale inventories; files deleted by retention jobs mid-audit; path construction bugs in generated manifests.
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
- {} doesn't support satisfyStoragePolicy
- {} doesn't support setStoragePolicy
- {} doesn't support unsetStoragePolicy
- {} doesn't support getStoragePolicy
- {} doesn't support getAllStoragePolicies
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/5a64827b04bb7007.
Report an issue: GitHub.