apache/hadoop · error · HadoopIllegalArgumentException

XAttr names can not be null or empty.

Error message

XAttr names can not be null or empty.

What it means

XAttrHelper.buildXAttrs(List<String>) converts a caller's list of prefixed xattr names into XAttr objects for the names-filtered xattr read (getXAttrs(path, names)). A null or empty list is rejected immediately with HadoopIllegalArgumentException, because HDFS requires at least one concrete attribute name for that RPC.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/XAttrHelper.java:163

   */
  public static String getPrefixedName(XAttr xAttr) {
    if (xAttr == null) {
      return null;
    }

    return getPrefixedName(xAttr.getNameSpace(), xAttr.getName());
  }

  public static String getPrefixedName(XAttr.NameSpace ns, String name) {
    return StringUtils.toLowerCase(ns.toString()) + "." + name;
  }

  /**
   * Build <code>XAttr</code> list from xattr name list.
   */
  public static List<XAttr> buildXAttrs(List<String> names) {
    if (names == null || names.isEmpty()) {
      throw new HadoopIllegalArgumentException("XAttr names can not be " +
          "null or empty.");
    }

    List<XAttr> xAttrs = Lists.newArrayListWithCapacity(names.size());
    for (String name : names) {
      xAttrs.add(buildXAttr(name, null));
    }
    return xAttrs;
  }
}

View on GitHub (pinned to 2add963021)

Solutions

  1. To read all xattrs, call dfs.getXAttrs(path) with no name list.
  2. Otherwise pass at least one valid prefixed name such as 'user.color'.
  3. Guard wrapper methods: translate null/empty filter lists into the get-all form.

Example fix

// before
List<String> names = request.getAttrs(); // may be empty
dfs.getXAttrs(path, names); // throws

// after
Map<String, byte[]> xattrs = (names == null || names.isEmpty())
    ? dfs.getXAttrs(path)
    : dfs.getXAttrs(path, names);
Defensive patterns

Strategy: validation

Validate before calling

if (names == null || names.isEmpty()) {
  // names-filtered RPC requires >= 1 name; use the get-all form instead
  xattrs = dfs.getXAttrs(path);
} else {
  xattrs = dfs.getXAttrs(path, names);
}

Prevention

When it happens

Trigger: dfs.getXAttrs(path, names) where names is null or Collections.emptyList(); also direct calls to XdfsHelper.buildXAttrs with an empty collection. getXAttrs(path) without a list is a different RPC and is fine.

Common situations: Wrapper APIs that forward a user-supplied filter list unchecked; code that builds the name list dynamically and passes it through empty; refactors that turn a fixed list into a computed one that can be empty.

Related errors


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