{"record":{"id":"65220759a3036d80","repo":"apache/hadoop","slug":"bad-element-in-ec-policy-configuration-file-tagn","errorCode":null,"errorMessage":"Bad element in EC policy configuration file: {tagName}","messagePattern":"Bad element in EC policy configuration file: (.+?)","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/util/ECPolicyLoader.java","lineNumber":177,"sourceCode":"  private Map<String, ECSchema> loadSchemas(Element root) {\n    NodeList elements = root.getElementsByTagName(\"schemas\")\n        .item(0).getChildNodes();\n    Map<String, ECSchema> schemas = new HashMap<String, ECSchema>();\n    for (int i = 0; i < elements.getLength(); i++) {\n      Node node = elements.item(i);\n      if (node instanceof Element) {\n        Element element = (Element) node;\n        if (\"schema\".equals(element.getTagName())) {\n          String schemaId = element.getAttribute(\"id\");\n          ECSchema schema = loadSchema(element);\n          if (!schemas.containsValue(schema)) {\n            schemas.put(schemaId, schema);\n          } else {\n            throw new RuntimeException(\"Repetitive schemas in EC policy\"\n                + \" configuration file: \" + schemaId);\n          }\n        } else {\n          throw new RuntimeException(\"Bad element in EC policy\"\n              + \" configuration file: \" + element.getTagName());\n        }\n      }\n    }\n\n    return schemas;\n  }\n\n  /**\n   * Load EC policies from root element in the XML configuration file.\n   * @param root root element\n   * @param schemas schema map\n   * @return EC policy list\n   */\n  private List<ErasureCodingPolicy> loadPolicies(\n      Element root, Map<String, ECSchema> schemas) {\n    NodeList elements = root.getElementsByTagName(\"policies\")\n        .item(0).getChildNodes();","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/util/ECPolicyLoader.java#L159-L195","documentation":"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.","triggerScenarios":"`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.","commonSituations":"Mixing Hadoop site-configuration habits (<name>/<property> blocks) into the EC policy file, or pasting the <policies> block inside <schemas> while reorganizing the file.","solutions":["Make <schemas> contain only <schema> elements; move <policy> elements into the <policies> block","Remove any <property>, <name>, or other configuration-style elements from <schemas>","Re-validate the structure with xmllint and retry `hdfs ec -loadPolicy`"],"exampleFix":"<!-- before -->\n<schemas>\n  <property><name>foo</name></property>\n  <schema id=\"rs-6-3\">...</schema>\n</schemas>\n\n<!-- after -->\n<schemas>\n  <schema id=\"rs-6-3\">...</schema>\n</schemas>","handlingStrategy":"validation","validationCode":"for (Node n : childrenOf(doc, \"schemas\")) {\n  if (n instanceof Element && !\"schema\".equals(((Element) n).getTagName())) {\n    throw new IllegalArgumentException(\"unexpected <\" + ((Element) n).getTagName() + \"> inside <schemas>\");\n  }\n}","typeGuard":null,"tryCatchPattern":"try { new ECPolicyLoader().loadPolicy(path); }\ncatch (RuntimeException e) {\n  LOG.error(\"EC policy file {} rejected: {}\", path, e.getMessage());\n}","preventionTips":["Keep the file's three sections strictly separated: layoutversion, schemas, policies","Do not paste <property> blocks from site XML into the policy file"],"tags":["hdfs","erasure-coding","ec-policy","xml","schema-validation"],"backgroundTag":"xml-config-invalid-element","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}