apache/hadoop · error · RuntimeException
Bad EC policy configuration file: no <policies> element
Error message
Bad EC policy configuration file: no <policies> element
What it means
Inside <configuration>, ECPolicyLoader validates three sections in order: <layoutversion>, then <schemas>, then <policies>. If layoutversion matches and schemas exist but no <policies> element is present - the element that actually carries the list of policy entries - loading aborts with 'Bad EC policy configuration file: no <policies> element'. The container validated fine but the payload is missing.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/util/ECPolicyLoader.java:111
dbf.setIgnoringComments(true);
DocumentBuilder builder = dbf.newDocumentBuilder();
Document doc = builder.parse(policyFile);
Element root = doc.getDocumentElement();
if (!"configuration".equals(root.getTagName())) {
throw new RuntimeException("Bad EC policy configuration file: "
+ "top-level element not <configuration>");
}
List<ErasureCodingPolicy> policies;
if (root.getElementsByTagName("layoutversion").getLength() > 0) {
if (loadLayoutVersion(root) == LAYOUT_VERSION) {
if (root.getElementsByTagName("schemas").getLength() > 0) {
Map<String, ECSchema> schemas = loadSchemas(root);
if (root.getElementsByTagName("policies").getLength() > 0) {
policies = loadPolicies(root, schemas);
} else {
throw new RuntimeException("Bad EC policy configuration file: "
+ "no <policies> element");
}
} else {
throw new RuntimeException("Bad EC policy configuration file: "
+ "no <schemas> element");
}
} else {
throw new RuntimeException("The parse failed because of "
+ "bad layoutversion value");
}
} else {
throw new RuntimeException("Bad EC policy configuration file: "
+ "no <layoutVersion> element");
}
return policies;
}
View on GitHub (pinned to 2add963021)
Solutions
- Add a <policies> element containing one <policy> entry per EC policy you want to add
- Check spelling and case - the loader matches the literal lowercase tag 'policies'
- Model the file on the shipped user-ec-policies.xml example
Example fix
<!-- before: layoutversion + schemas only -->
<configuration>
<layoutversion>1</layoutversion>
<schemas>...</schemas>
</configuration>
<!-- after -->
<configuration>
<layoutversion>1</layoutversion>
<schemas>...</schemas>
<policies>
<policy><name>MY-POLICY</name><!-- schemaId, cellsize... --></policy>
</policies>
</configuration> Defensive patterns
Strategy: validation
Validate before calling
Element root = doc.getDocumentElement();
boolean hasPolicies = root.getElementsByTagName("policies").getLength() > 0;
if (!hasPolicies) { /* reject before loadPolicy */ } Try / catch
try {
new ECPolicyLoader().loadPolicy(path);
} catch (RuntimeException e) {
if (e.getMessage() != null && e.getMessage().contains("no <policies> element")) {
// add a <policies> block with <policy> entries and retry
} else { throw e; }
} Prevention
- Check required sections (layoutversion, schemas, policies) as a deployment lint step
- Beware typos and case: the loader matches literal lowercase tags
When it happens
Trigger: `hdfs ec -addPolicies` with a file that has <layoutversion> and <schemas> but no <policies> element: the block was deleted, commented out, or misspelled (e.g. <policy> or <Policies>).
Common situations: Typos in element names; blocks commented out during debugging; templates trimmed too aggressively.
Related errors
- Bad EC policy configuration file: no <schemas> element
- Bad EC policy configuration file: top-level element not <con
- Bad element in EC policy configuration file: {tagName}
- Value of <{tagName}> is null
- Bad policy is found in EC policy configuration file
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/197f19549feb7bba.
Report an issue: GitHub.