apache/hadoop · error · UnsupportedOperationException

XAttrs are not supported on symlinks

Error message

XAttrs are not supported on symlinks

What it means

INodeSymlink.getXAttrFeature unconditionally throws UnsupportedOperationException("XAttrs are not supported on symlinks"). Reading extended attributes of a symlink inode (or internal logic that consults xattrs — encryption zone markers, raw xattr namespaces) reaches this method and fails, because symlink inodes carry no XAttrFeature storage.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeSymlink.java:129

  @Override
  public void accept(NamespaceVisitor visitor, int snapshot) {
    visitor.visitSymlink(this, snapshot);
  }

  @Override
  public void removeAclFeature() {
    throw new UnsupportedOperationException("ACLs are not supported on symlinks");
  }

  @Override
  public void addAclFeature(AclFeature f) {
    throw new UnsupportedOperationException("ACLs are not supported on symlinks");
  }

  @Override
  final XAttrFeature getXAttrFeature(int snapshotId) {
    throw new UnsupportedOperationException("XAttrs are not supported on symlinks");
  }
  
  @Override
  public void removeXAttrFeature() {
    throw new UnsupportedOperationException("XAttrs are not supported on symlinks");
  }
  
  @Override
  public void addXAttrFeature(XAttrFeature f) {
    throw new UnsupportedOperationException("XAttrs are not supported on symlinks");
  }

  @Override
  public byte getStoragePolicyID() {
    throw new UnsupportedOperationException(
        "Storage policy are not supported on symlinks");
  }

View on GitHub (pinned to 2add963021)

Solutions

  1. Resolve the symlink target (FileContext/Path.resolve) and read xattrs from the destination
  2. Skip symlinks when enumerating xattrs across a tree
  3. Handle UnsupportedOperationException for symlinks explicitly so scans continue

Example fix

// before
byte[] v = fs.getXAttr(path);   // path is a symlink -> throws

// after
Path target = path.resolve(fs); // resolve link chain
byte[] v = fs.getXAttr(target);
Defensive patterns

Strategy: type-guard

Validate before calling

FileStatus st = fs.getFileStatus(p);
Path target = st.isSymlink() ? fs.getFileStatus(p).getSymlink() : p;
Map<String, byte[]> xattrs = fs.getXAttrs(target);

Type guard

boolean xattrReadable(FileSystem fs, Path p) throws IOException {
  return !fs.getFileStatus(p).isSymlink();
}

Try / catch

catch (UnsupportedOperationException e) {
  if (e.getMessage() != null && e.getMessage().contains("XAttrs are not supported on symlinks")) {
    return Collections.emptyMap();  // links carry no xattrs by design
  }
  throw e;
}

Prevention

When it happens

Trigger: getXAttrs/getXAttr on a symlink path; internal attribute lookups (e.g. encryption zone or trusted-namespace checks) operating directly on a symlink inode rather than its resolved target.

Common situations: Audit/security scanners enumerating xattrs recursively over trees with symlinks; tooling that reads raw.* xattrs hitting compatibility links; distcp -p preserving xattrs.

Related errors


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