{"record":{"id":"120258955a93bbcc","repo":"apache/hadoop","slug":"value-of-tagname-is-null","errorCode":null,"errorMessage":"Value of <{tagName}> is null","messagePattern":"Value of <(.+?)> is null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/util/ECPolicyLoader.java","lineNumber":268,"sourceCode":"\n    for (int i = 0; i < fields.getLength(); i++) {\n      Node fieldNode = fields.item(i);\n      if (fieldNode instanceof Element) {\n        Element field = (Element) fieldNode;\n        String tagName = field.getTagName();\n        if (\"k\".equals(tagName)) {\n          tagName = \"numDataUnits\";\n        } else if (\"m\".equals(tagName)) {\n          tagName = \"numParityUnits\";\n        }\n\n        // Get the nonnull text value.\n        Text text = (Text) field.getFirstChild();\n        if (text != null) {\n          String value = text.getData().trim();\n          schemaOptions.put(tagName, value);\n        } else {\n          throw new IllegalArgumentException(\"Value of <\" + tagName\n              + \"> is null\");\n        }\n      }\n    }\n\n    return new ECSchema(schemaOptions);\n  }\n\n  /**\n   * Load a EC policy from a policy element in the XML configuration file.\n   * @param element EC policy element\n   * @param schemas all valid schemas of the EC policy file\n   * @return EC policy\n   */\n  private ErasureCodingPolicy loadPolicy(Element element,\n                                         Map<String, ECSchema> schemas) {\n    NodeList fields = element.getChildNodes();\n    ECSchema schema = null;","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/util/ECPolicyLoader.java#L250-L286","documentation":"ECPolicyLoader.loadSchema() reads each child field of a <schema> element and requires a non-null first text node. This IllegalArgumentException means a field element inside <schema> is empty — e.g. <k/>, <m/>, or <codec/> with no text. The message names the offending tag; k/m are reported under their internal names numDataUnits/numParityUnits.","triggerScenarios":"`hdfs ec -loadPolicy` where a schema field is an empty element: <schema id=\"x\"><k>6</k><m/></schema> reports 'Value of <numParityUnits> is null'.","commonSituations":"Deleting a field's value while editing the template, or authoring a new schema and forgetting to fill in codec or m.","solutions":["Give every field inside <schema> a text value: <k>6</k> <m>3</m> <codec>rs</codec>","Map the reported name back to the XML tag: numDataUnits=<k>, numParityUnits=<m>","Re-run `hdfs ec -loadPolicy` after filling in the empty element"],"exampleFix":"<!-- before -->\n<schema id=\"rs-6-3\">\n  <k>6</k><m></m><codec>rs</codec>\n</schema>\n\n<!-- after -->\n<schema id=\"rs-6-3\">\n  <k>6</k><m>3</m><codec>rs</codec>\n</schema>","handlingStrategy":"validation","validationCode":"for (Element schema : schemaElements(doc)) {\n  for (Node c = schema.getFirstChild(); c != null; c = c.getNextSibling()) {\n    if (c instanceof Element && c.getFirstChild() == null) {\n      throw new IllegalArgumentException(\"empty field <\" + ((Element) c).getTagName() + \"> in schema \" + schema.getAttribute(\"id\"));\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":"try { new ECPolicyLoader().loadPolicy(path); }\ncatch (IllegalArgumentException e) {\n  LOG.error(\"EC policy file {} rejected: {}\", path, e.getMessage()); // numDataUnits=<k>, numParityUnits=<m>\n}","preventionTips":["Fill every field when adding a schema: k, m, codec","Map reported names back: numDataUnits is <k>, numParityUnits is <m>"],"tags":["hdfs","erasure-coding","ec-policy","xml","schema-validation"],"backgroundTag":"xml-config-missing-element","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}