apache/hadoop · warning · XAttrNotFoundException
At least one of the attributes provided was not found.
Error message
At least one of the attributes provided was not found.
What it means
getXAttrs with a name list first filters the inode's xattrs down to what the caller may see (XAttrPermissionFilter). If nothing survives, because the file has no xattrs at all or only restricted-namespace entries the caller cannot read, filteredAll is empty and the request fails with XAttrNotFoundException instead of returning an empty list.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirXAttrOp.java:118
checkXAttrsConfigFlag(fsd);
final boolean isRawPath = FSDirectory.isReservedRawName(src);
boolean getAll = xAttrs == null || xAttrs.isEmpty();
if (!getAll) {
XAttrPermissionFilter.checkPermissionForApi(pc, xAttrs, isRawPath);
}
final INodesInPath iip = fsd.resolvePath(pc, src, DirOp.READ);
if (fsd.isPermissionEnabled()) {
fsd.checkPathAccess(pc, iip, FsAction.READ);
}
List<XAttr> all = FSDirXAttrOp.getXAttrs(fsd, iip);
List<XAttr> filteredAll = XAttrPermissionFilter.
filterXAttrsForApi(pc, all, isRawPath);
if (getAll) {
return filteredAll;
}
if (filteredAll == null || filteredAll.isEmpty()) {
throw new XAttrNotFoundException();
}
List<XAttr> toGet = Lists.newArrayListWithCapacity(xAttrs.size());
for (XAttr xAttr : xAttrs) {
boolean foundIt = false;
for (XAttr a : filteredAll) {
if (xAttr.getNameSpace() == a.getNameSpace() && xAttr.getName().equals(
a.getName())) {
toGet.add(a);
foundIt = true;
break;
}
}
if (!foundIt) {
throw new XAttrNotFoundException();
}
}
return toGet;
}View on GitHub (pinned to 2add963021)
Solutions
- Call fs.listXAttrs(path) first and request only names it returns; an empty list means none, handle as absent
- Catch XAttrNotFoundException (an IOException subclass) and treat it as attribute-absent
- Run with owner or superuser privileges if restricted-namespace xattrs are genuinely expected
Example fix
// before
byte[] v = fs.getXAttr(path, "user.mytag"); // throws on xattr-less file
// after
byte[] v = null;
if (fs.listXAttrs(path).contains("user.mytag")) {
v = fs.getXAttr(path, "user.mytag");
} Defensive patterns
Strategy: validation
Validate before calling
List<String> present = fs.listXAttrs(path);
if (!present.contains("user.mytag")) {
return Optional.empty();
}
return Optional.of(fs.getXAttr(path, "user.mytag")); Try / catch
try {
return Optional.of(fs.getXAttr(path, name));
} catch (XAttrNotFoundException e) {
return Optional.empty(); // attribute absent: not an error for optional metadata
} Prevention
- Treat xattrs as optional metadata: list first or catch not-found
- Remember privileges filter raw/trusted/security namespaces out of the API view
- Use the user. namespace for application metadata
When it happens
Trigger: fs.getXAttr(path, name) or the multi-name getXAttrs on a file with no visible xattrs; typical when probing raw./trusted./security. namespaces without the privileges that let those attributes pass the filter.
Common situations: Probing optional metadata markers that may or may not exist; non-privileged readers of files whose only xattrs live in restricted namespaces.
Related errors
- No matching attributes found for remove operation
- Permission denied: user=%s, path="%s":%s:%s:%s%s
- {} doesn't support modifyAclEntries
- {} doesn't support removeAclEntries
- {} doesn't support removeAcl
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/413289e285abdee2.
Report an issue: GitHub.