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

  1. Call fs.listXAttrs(path) first and request only names it returns; an empty list means none, handle as absent
  2. Catch XAttrNotFoundException (an IOException subclass) and treat it as attribute-absent
  3. 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

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


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/413289e285abdee2. Report an issue: GitHub.