{"record":{"id":"bba24c02eb9ec5c5","repo":"apache/hadoop","slug":"doesn-t-support-listxattrs","errorCode":null,"errorMessage":"{} doesn't support listXAttrs","messagePattern":"(.+?) doesn't support listXAttrs","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java","lineNumber":1451,"sourceCode":"    throw new UnsupportedOperationException(getClass().getSimpleName()\n        + \" doesn't support getXAttrs\");\n  }\n\n  /**\n   * Get all of the xattr names for a file or directory.\n   * Only the xattr names for which the logged-in user has permissions to view\n   * are returned.\n   * <p>\n   * Refer to the HDFS extended attributes user documentation for details.\n   *\n   * @param path Path to get extended attributes\n   * @return {@literal Map<String, byte[]>} describing the XAttrs of the file\n   * or directory\n   * @throws IOException raised on errors performing I/O.\n   */\n  public List<String> listXAttrs(Path path)\n          throws IOException {\n    throw new UnsupportedOperationException(getClass().getSimpleName()\n            + \" doesn't support listXAttrs\");\n  }\n\n  /**\n   * Remove an xattr of a file or directory.\n   * The name must be prefixed with the namespace followed by \".\". For example,\n   * \"user.attr\".\n   * <p>\n   * Refer to the HDFS extended attributes user documentation for details.\n   *\n   * @param path Path to remove extended attribute\n   * @param name xattr name\n   * @throws IOException raised on errors performing I/O.\n   */\n  public void removeXAttr(Path path, String name) throws IOException {\n    throw new UnsupportedOperationException(getClass().getSimpleName()\n        + \" doesn't support removeXAttr\");\n  }","sourceCodeStart":1433,"sourceCodeEnd":1469,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java#L1433-L1469","documentation":"FileContext resolves each URI to a per-scheme AbstractFileSystem implementation, and the base class's listXAttrs(Path) is a stub that always throws UnsupportedOperationException, filling the concrete subclass name into the message (e.g. \"S3A doesn't support listXAttrs\"). Extended attributes are an optional feature: only implementations that override this method (HDFS and WebHDFS) can succeed. Hitting this error means the mounted filesystem for that URI does not implement the xattr API at all - it is not a per-file or permission condition.","triggerScenarios":"Calling FileContext.listXAttrs(path) on a scheme whose AbstractFileSystem keeps the default stub: object stores (s3a, gs, wasb/abfs), ftp/sftp, and the local FileContext backend in versions where it does not override xattr ops. Also triggered indirectly by DistCp run with -p xattr preservation writing to such a target, or by generic FS tooling that enumerates xattrs for every path.","commonSituations":"Application code written and tested against HDFS is repointed at an object store or file:// (unit tests, local IDE runs, fs.defaultFS change), and the xattr calls that worked on HDFS now throw. Metadata stored in user.* xattrs (labels, lineage, Ranger tags) has no equivalent on the new store.","solutions":["Read the class name in the message to identify which implementation is actually mounted for the path, and confirm the URI scheme; only hdfs:// and webhdfs:// implement listXAttrs.","Route the operation to HDFS (use an hdfs:// path, or DistributedFileSystem via FileSystem.get, which overrides listXAttrs).","If xattrs are optional for your app, catch UnsupportedOperationException and degrade to \"no xattrs\" behavior.","For DistCp, drop xattr from the -p attribute list when the destination filesystem does not support it."],"exampleFix":"// before\nList<String> names = fc.listXAttrs(path); // throws on s3a:// or file://\n\n// after\nList<String> names;\ntry {\n  names = fc.listXAttrs(path);\n} catch (UnsupportedOperationException e) {\n  names = Collections.emptyList(); // scheme does not implement xattrs\n}","handlingStrategy":"try-catch","validationCode":"static boolean supportsListXAttrs(FileContext fc, Path probe) throws IOException {\n  try {\n    fc.listXAttrs(probe);\n    return true;\n  } catch (UnsupportedOperationException e) {\n    return false;\n  } catch (IOException e) {\n    return true; // supported, but the probe hit an I/O problem\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  names = fc.listXAttrs(path);\n} catch (UnsupportedOperationException e) {\n  // optional feature absent on this scheme: degrade, do not retry\n  names = Collections.emptyList();\n}","preventionTips":["Check path.toUri().getScheme() before optional metadata APIs; only hdfs/webhdfs implement xattrs","Run one capability probe per filesystem at startup and cache the result","Keep a per-scheme feature matrix instead of assuming HDFS semantics everywhere","Do not pass -p xattr to distcp when the target is an object store"],"tags":["hadoop","filesystem","xattr","filecontext","unsupportedoperationexception"],"backgroundTag":"xattr-unsupported","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}