{"record":{"id":"e71dae79a65f197f","repo":"apache/hadoop","slug":"xattrs-not-supported-for-file-system-uri","errorCode":null,"errorMessage":"XAttrs not supported for file system: {uri}","messagePattern":"XAttrs not supported for file system: (.+?)","errorType":"exception","errorClass":"XAttrsNotSupportedException","httpStatus":null,"severity":"error","filePath":"hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/util/DistCpUtils.java","lineNumber":516,"sourceCode":"        + fs.getUri());\n    }\n  }\n  \n  /**\n   * Determines if a file system supports XAttrs by running a getXAttrs request\n   * on the file system root. This method is used before distcp job submission\n   * to fail fast if the user requested preserving XAttrs, but the file system\n   * cannot support XAttrs.\n   * \n   * @param fs FileSystem to check\n   * @throws XAttrsNotSupportedException if fs does not support XAttrs\n   */\n  public static void checkFileSystemXAttrSupport(FileSystem fs)\n      throws XAttrsNotSupportedException {\n    try {\n      fs.getXAttrs(new Path(Path.SEPARATOR));\n    } catch (Exception e) {\n      throw new XAttrsNotSupportedException(\"XAttrs not supported for file system: \"\n        + fs.getUri());\n    }\n  }\n\n  /**\n   * String utility to convert a number-of-bytes to human readable format.\n   */\n  private static final ThreadLocal<DecimalFormat> FORMATTER\n                        = new ThreadLocal<DecimalFormat>() {\n    @Override\n    protected DecimalFormat initialValue() {\n      return new DecimalFormat(\"0.0\");\n    }\n  };\n\n  public static DecimalFormat getFormatter() {\n    return FORMATTER.get();\n  }","sourceCodeStart":498,"sourceCodeEnd":534,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/util/DistCpUtils.java#L498-L534","documentation":"Pre-submission fail-fast check for XAttr preservation (-px): DistCpUtils.checkFileSystemXAttrSupport() calls fs.getXAttrs(new Path(\"/\")) and, if it throws, raises CopyListing.XAttrsNotSupportedException (the DistCp CLI exits with XATTRS_NOT_SUPPORTED = -4). This prevents discovering mid-job that extended attributes cannot be preserved.","triggerScenarios":"-px against a filesystem without XAttr support (most object stores, local FS, older HDFS builds); XAttrs disabled on HDFS; raw.* xattr copying (.reserved/raw) against a non-HDFS target; getXAttrs failing on the root path.","commonSituations":"HDFS-to-S3 replication pipelines carrying -px; security tooling that depends on raw.* xattrs; mixed-version clusters where only one side supports XAttrs.","solutions":["Drop 'x' from the -p list when either endpoint lacks XAttr support","For HDFS targets, confirm the version supports XAttrs and they are enabled","Probe before submitting: fs.getXAttrs(new Path(\"/\")) in a try/catch","If XAttrs are required, keep the destination on an XAttr-capable filesystem such as HDFS"],"exampleFix":"# before: S3A target has no XAttrs -> XAttrsNotSupportedException\nhadoop distcp -p x hdfs://nn/src s3a://bucket/dst\n\n# after\nhadoop distcp -p hdfs://nn/src s3a://bucket/dst","handlingStrategy":"validation","validationCode":"static boolean supportsXAttrs(FileSystem fs) {\n  try {\n    fs.getXAttrs(new Path(Path.SEPARATOR));\n    return true;\n  } catch (Exception e) {\n    return false;\n  }\n}\n// drop FileAttribute.XATTR from -p when supportsXAttrs(source/target) is false","typeGuard":null,"tryCatchPattern":"try {\n  new DistCp(options, conf).execute();\n} catch (CopyListing.XAttrsNotSupportedException e) {\n  // retry with 'x' removed from the preserve set (CLI exits -4 instead)\n}","preventionTips":["Probe getXAttrs('/') on both endpoints before requesting -px","Remember raw.* xattr copying only works between HDFS endpoints","Keep preserve flags minimal: only request what both filesystems support"],"tags":["distcp","hadoop","xattr","preserve","filesystem-capability"],"backgroundTag":"unsupported-filesystem-feature","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}