apache/hadoop · error · UnsupportedOperationException

{} doesn't support getXAttr

Error message

{} doesn't support getXAttr

What it means

FileSystem.getXAttr(Path, String) is optional; the base class throws UnsupportedOperationException with getClass().getSimpleName() + " doesn't support getXAttr". It reads one named xattr; implemented by the HDFS-family clients (DistributedFileSystem, WebHdfsFileSystem, HttpFSFileSystem) and pass-through wrappers, not by local filesystem or the common object-store connectors.

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java:3286

        + " doesn't support setXAttr");
  }

  /**
   * Get an xattr name and value for a file or directory.
   * The name must be prefixed with the namespace followed by ".". For example,
   * "user.attr".
   * <p>
   * Refer to the HDFS extended attributes user documentation for details.
   *
   * @param path Path to get extended attribute
   * @param name xattr name.
   * @return byte[] xattr value.
   * @throws IOException IO failure
   * @throws UnsupportedOperationException if the operation is unsupported
   *         (default outcome).
   */
  public byte[] getXAttr(Path path, String name) throws IOException {
    throw new UnsupportedOperationException(getClass().getSimpleName()
        + " doesn't support getXAttr");
  }

  /**
   * Get all of the xattr name/value pairs for a file or directory.
   * Only those xattrs which the logged-in user has permissions to view
   * are returned.
   * <p>
   * Refer to the HDFS extended attributes user documentation for details.
   *
   * @param path Path to get extended attributes
   * @return Map describing the XAttrs of the file or directory
   * @throws IOException IO failure
   * @throws UnsupportedOperationException if the operation is unsupported
   *         (default outcome).
   */
  public Map<String, byte[]> getXAttrs(Path path) throws IOException {
    throw new UnsupportedOperationException(getClass().getSimpleName()

View on GitHub (pinned to 2add963021)

Solutions

  1. Probe fs.hasPathCapability(path, CommonPathCapabilities.FS_XATTRS) before reading
  2. Store the same metadata in a sidecar file or catalog for non-HDFS paths and read from there
  3. Catch UnsupportedOperationException and treat the file as untagged (safe default) rather than failing the job
  4. Scope attribute-reading code to hdfs:// URIs

Example fix

// before
byte[] tag = fs.getXAttr(path, "user.ranger.tag"); // throws

// after
byte[] tag = null;
if (fs.hasPathCapability(path, CommonPathCapabilities.FS_XATTRS)) {
  tag = fs.getXAttr(path, "user.ranger.tag");
} else {
  tag = readSidecar(path, "ranger.tag"); // null when untagged
}
Defensive patterns

Strategy: try-catch

Validate before calling

byte[] value = null;
if (fs.hasPathCapability(path, CommonPathCapabilities.FS_XATTRS)) {
  value = fs.getXAttr(path, name);
} else {
  value = readSidecar(path, name); // null when untagged
}

Type guard

static boolean supportsXattrRead(FileSystem fs) {
  return fs instanceof DistributedFileSystem
      || fs instanceof WebHdfsFileSystem;
}

Try / catch

try {
  return fs.getXAttr(path, name);
} catch (UnsupportedOperationException e) {
  return null; // store has no xattrs: treat file as untagged
}

Prevention

When it happens

Trigger: Calling fs.getXAttr(path, name) on file://, s3a://, gs://, har:// or a custom FileSystem; annotation/policy readers that fetch a specific attribute (e.g., "user.ranger.tag") for every file processed.

Common situations: Policy engines reading tags from paths that include non-HDFS mounts; tooling developed against HDFS and reused after a partial migration to object storage.

Related errors


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