{"record":{"id":"5ac75901af52c94c","repo":"apache/hadoop","slug":"doesn-t-support-setxattr-5ac759","errorCode":null,"errorMessage":"{} doesn't support setXAttr","messagePattern":"(.+?) doesn't support setXAttr","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java","lineNumber":3267,"sourceCode":"\n  /**\n   * Set 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 modify\n   * @param name xattr name.\n   * @param value xattr value.\n   * @param flag xattr set flag\n   * @throws IOException IO failure\n   * @throws UnsupportedOperationException if the operation is unsupported\n   *         (default outcome).\n   */\n  public void setXAttr(Path path, String name, byte[] value,\n      EnumSet<XAttrSetFlag> flag) throws IOException {\n    throw new UnsupportedOperationException(getClass().getSimpleName()\n        + \" 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 {","sourceCodeStart":3249,"sourceCodeEnd":3285,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java#L3249-L3285","documentation":"FileSystem.setXAttr(Path, String, byte[], EnumSet<XAttrSetFlag>) is optional; the base class throws UnsupportedOperationException with getClass().getSimpleName() + \" doesn't support setXAttr\". Extended attributes are an HDFS feature (namespaces like user.* and trusted.*); implemented by DistributedFileSystem, WebHdfsFileSystem, HttpFSFileSystem and pass-throughs. Local filesystem and S3A/GCS-style connectors throw. Note: on HDFS, even with the override, server-side rules (namespace restrictions) produce separate IOExceptions — this UOE is purely about the client implementation lacking the feature.","triggerScenarios":"Calling fs.setXAttr(path, \"user.tag\", value, flags) on file://, s3a://, gs://, har:// or a custom FileSystem; metadata-tagging frameworks (Ranger tag sync, encryption-zone tooling, app-level annotations) attaching attributes unconditionally.","commonSituations":"Tagging/policy pipelines run in local tests or against object stores; distcp -p preserving xattrs to a non-HDFS target; migrations off HDFS where tooling still stamps attributes.","solutions":["Probe fs.hasPathCapability(path, CommonPathCapabilities.FS_XATTRS) before tagging","On stores without xattrs, persist metadata in sidecar files (path + '.meta') or an external catalog","distcp: drop xattr (and acl) preservation for non-HDFS destinations","Catch UnsupportedOperationException and skip tagging with a warn — never retry the call"],"exampleFix":"// before\nfs.setXAttr(path, \"user.provenance\", value,\n    EnumSet.of(XAttrSetFlag.CREATE));\n// throws on LocalFileSystem/S3A\n\n// after\nif (fs.hasPathCapability(path, CommonPathCapabilities.FS_XATTRS)) {\n  fs.setXAttr(path, \"user.provenance\", value, EnumSet.of(XAttrSetFlag.CREATE));\n} else {\n  writeSidecar(path, \"provenance\", value);\n}","handlingStrategy":"try-catch","validationCode":"import org.apache.hadoop.fs.CommonPathCapabilities;\n\nif (fs.hasPathCapability(path, CommonPathCapabilities.FS_XATTRS)) {\n  fs.setXAttr(path, \"user.tag\", value, EnumSet.of(XAttrSetFlag.CREATE));\n} else {\n  writeSidecar(path, \"tag\", value);\n}","typeGuard":"static boolean supportsXattrWrite(FileSystem fs) {\n  return fs instanceof DistributedFileSystem\n      || fs instanceof WebHdfsFileSystem;\n}","tryCatchPattern":"try {\n  fs.setXAttr(path, name, value, flags);\n} catch (UnsupportedOperationException e) {\n  // class in e.getMessage() has no xattr storage: write sidecar metadata instead\n}","preventionTips":["Design tagging layers with a pluggable backend (xattr | sidecar | catalog) from day one","Capability-probe per store and cache; avoid per-call try/catch in hot loops","distcp: drop -p xattr for non-HDFS endpoints"],"tags":["hadoop","filesystem","hdfs","xattr","extended-attributes","unsupportedoperationexception","metadata"],"backgroundTag":"filesystem-xattr-unsupported","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}