{"record":{"id":"09b8d30f45d77745","repo":"apache/hadoop","slug":"doesn-t-support-getxattr-09b8d3","errorCode":null,"errorMessage":"{} doesn't support getXAttr","messagePattern":"(.+?) doesn't support getXAttr","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java","lineNumber":3286,"sourceCode":"        + \" doesn't support setXAttr\");\n  }\n\n  /**\n   * Get an xattr name and value for 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 get extended attribute\n   * @param name xattr name.\n   * @return byte[] xattr value.\n   * @throws IOException IO failure\n   * @throws UnsupportedOperationException if the operation is unsupported\n   *         (default outcome).\n   */\n  public byte[] getXAttr(Path path, String name) throws IOException {\n    throw new UnsupportedOperationException(getClass().getSimpleName()\n        + \" doesn't support getXAttr\");\n  }\n\n  /**\n   * Get all of the xattr name/value pairs for a file or directory.\n   * Only those xattrs 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 Map describing the XAttrs of the file or directory\n   * @throws IOException IO failure\n   * @throws UnsupportedOperationException if the operation is unsupported\n   *         (default outcome).\n   */\n  public Map<String, byte[]> getXAttrs(Path path) throws IOException {\n    throw new UnsupportedOperationException(getClass().getSimpleName()","sourceCodeStart":3268,"sourceCodeEnd":3304,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java#L3268-L3304","documentation":"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.","triggerScenarios":"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.","commonSituations":"Policy engines reading tags from paths that include non-HDFS mounts; tooling developed against HDFS and reused after a partial migration to object storage.","solutions":["Probe fs.hasPathCapability(path, CommonPathCapabilities.FS_XATTRS) before reading","Store the same metadata in a sidecar file or catalog for non-HDFS paths and read from there","Catch UnsupportedOperationException and treat the file as untagged (safe default) rather than failing the job","Scope attribute-reading code to hdfs:// URIs"],"exampleFix":"// before\nbyte[] tag = fs.getXAttr(path, \"user.ranger.tag\"); // throws\n\n// after\nbyte[] tag = null;\nif (fs.hasPathCapability(path, CommonPathCapabilities.FS_XATTRS)) {\n  tag = fs.getXAttr(path, \"user.ranger.tag\");\n} else {\n  tag = readSidecar(path, \"ranger.tag\"); // null when untagged\n}","handlingStrategy":"try-catch","validationCode":"byte[] value = null;\nif (fs.hasPathCapability(path, CommonPathCapabilities.FS_XATTRS)) {\n  value = fs.getXAttr(path, name);\n} else {\n  value = readSidecar(path, name); // null when untagged\n}","typeGuard":"static boolean supportsXattrRead(FileSystem fs) {\n  return fs instanceof DistributedFileSystem\n      || fs instanceof WebHdfsFileSystem;\n}","tryCatchPattern":"try {\n  return fs.getXAttr(path, name);\n} catch (UnsupportedOperationException e) {\n  return null; // store has no xattrs: treat file as untagged\n}","preventionTips":["Policy/tag readers should treat 'store has no xattrs' as untagged, not fatal","Read tags from an external catalog when paths may live on object stores","Scope xattr reads to hdfs:// URIs in mixed-scheme deployments"],"tags":["hadoop","filesystem","hdfs","xattr","unsupportedoperationexception","metadata"],"backgroundTag":"filesystem-xattr-unsupported","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}