apache/hadoop · error · RuntimeException

Bad element in EC policy configuration file: {tagName}

Error message

Bad element in EC policy configuration file: {tagName}

What it means

While iterating children of <schemas>, ECPolicyLoader.loadSchemas() hit an Element whose tag is not <schema> and threw RuntimeException with that tag name. Only Element nodes are inspected (whitespace and comments are ignored), so this means a real stray element sits inside the <schemas> container.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/util/ECPolicyLoader.java:177

  private Map<String, ECSchema> loadSchemas(Element root) {
    NodeList elements = root.getElementsByTagName("schemas")
        .item(0).getChildNodes();
    Map<String, ECSchema> schemas = new HashMap<String, ECSchema>();
    for (int i = 0; i < elements.getLength(); i++) {
      Node node = elements.item(i);
      if (node instanceof Element) {
        Element element = (Element) node;
        if ("schema".equals(element.getTagName())) {
          String schemaId = element.getAttribute("id");
          ECSchema schema = loadSchema(element);
          if (!schemas.containsValue(schema)) {
            schemas.put(schemaId, schema);
          } else {
            throw new RuntimeException("Repetitive schemas in EC policy"
                + " configuration file: " + schemaId);
          }
        } else {
          throw new RuntimeException("Bad element in EC policy"
              + " configuration file: " + element.getTagName());
        }
      }
    }

    return schemas;
  }

  /**
   * Load EC policies from root element in the XML configuration file.
   * @param root root element
   * @param schemas schema map
   * @return EC policy list
   */
  private List<ErasureCodingPolicy> loadPolicies(
      Element root, Map<String, ECSchema> schemas) {
    NodeList elements = root.getElementsByTagName("policies")
        .item(0).getChildNodes();

View on GitHub (pinned to 2add963021)

Solutions

  1. Make <schemas> contain only <schema> elements; move <policy> elements into the <policies> block
  2. Remove any <property>, <name>, or other configuration-style elements from <schemas>
  3. Re-validate the structure with xmllint and retry `hdfs ec -loadPolicy`

Example fix

<!-- before -->
<schemas>
  <property><name>foo</name></property>
  <schema id="rs-6-3">...</schema>
</schemas>

<!-- after -->
<schemas>
  <schema id="rs-6-3">...</schema>
</schemas>
Defensive patterns

Strategy: validation

Validate before calling

for (Node n : childrenOf(doc, "schemas")) {
  if (n instanceof Element && !"schema".equals(((Element) n).getTagName())) {
    throw new IllegalArgumentException("unexpected <" + ((Element) n).getTagName() + "> inside <schemas>");
  }
}

Try / catch

try { new ECPolicyLoader().loadPolicy(path); }
catch (RuntimeException e) {
  LOG.error("EC policy file {} rejected: {}", path, e.getMessage());
}

Prevention

When it happens

Trigger: `hdfs ec -loadPolicy` where <schemas> contains anything other than <schema> elements — e.g. a <property> block pasted from a *-site.xml, or a <policy> element nested in the wrong container.

Common situations: Mixing Hadoop site-configuration habits (<name>/<property> blocks) into the EC policy file, or pasting the <policies> block inside <schemas> while reorganizing the file.

Related errors


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