{"record":{"id":"b9f61a81ca680a31","repo":"apache/hadoop","slug":"bad-policy-is-found-in-ec-policy-configuration-fil","errorCode":null,"errorMessage":"Bad policy is found in EC policy configuration file","messagePattern":"Bad policy is found 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":323,"sourceCode":"              } catch (NumberFormatException e) {\n                throw new IllegalArgumentException(\"Bad EC policy cellsize\"\n                    + \" value \" + value + \" is found. It should be an integer\");\n              }\n            } else {\n              LOG.warn(\"Invalid tagName: \" + tagName);\n            }\n          }\n        } else {\n          throw new IllegalArgumentException(\"Value of <\" + tagName\n              + \"> is null\");\n        }\n      }\n    }\n\n    if (schema != null && cellSize > 0) {\n      return new ErasureCodingPolicy(schema, cellSize);\n    } else {\n      throw new RuntimeException(\"Bad policy is found in\"\n          + \" EC policy configuration file\");\n    }\n  }\n}\n","sourceCodeStart":305,"sourceCodeEnd":328,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/util/ECPolicyLoader.java#L305-L328","documentation":"Final validation in ECPolicyLoader.loadPolicy(Element, Map): a policy is accepted only if the referenced schema was resolved (schema != null, i.e. the <schema> text matches an id defined in <schemas>) AND the parsed cellSize is > 0. Anything else — unknown schema id, missing <cellsize> (defaults to 0), or cellsize <= 0 — throws this RuntimeException without naming the policy.","triggerScenarios":"`hdfs ec -loadPolicy` where a policy references a schema id that is not defined in the <schemas> block (e.g. 'rs-3-2' with no matching <schema id=\"rs-3-2\">), or the policy has no <cellsize> element at all so cellSize stays 0.","commonSituations":"Renaming a schema id but not the policies referencing it; deleting a schema while leaving its policies; authoring a policy with only <name> and <schema> because the template's cellsize line was lost.","solutions":["Check every <policy><schema> value against the ids in <schemas> and fix typos or renames","Add or correct the cell size: <cellsize>1048576</cellsize> (must be a positive integer)","Since the message does not name the policy, bisect: load with a single policy first, then add the rest back one by one"],"exampleFix":"<!-- before -->\n<schemas>\n  <schema id=\"rs-6-3\">...</schema>\n</schemas>\n<policies>\n  <policy>\n    <name>RS-6-3</name>\n    <schema>rs-63</schema>  <!-- typo: no such id -->\n    <cellsize>1048576</cellsize>\n  </policy>\n</policies>\n\n<!-- after -->\n<schema>rs-6-3</schema>","handlingStrategy":"validation","validationCode":"Set<String> schemaIds = idsOf(doc, \"schema\");\nfor (Element p : policyElements(doc)) {\n  String ref = textOf(p, \"schema\");\n  if (!schemaIds.contains(ref)) throw new IllegalArgumentException(\"policy references unknown schema id \" + ref);\n  if (Integer.parseInt(textOf(p, \"cellsize\")) <= 0) throw new IllegalArgumentException(\"policy cellsize must be > 0\");\n}","typeGuard":null,"tryCatchPattern":"try { new ECPolicyLoader().loadPolicy(path); }\ncatch (RuntimeException e) {\n  LOG.error(\"EC policy file {} rejected: {}\", path, e.getMessage()); // bisect policies if unclear\n}","preventionTips":["Keep schema ids and policy references in one place; rename both together","Load-test new policy files on a test cluster before production `hdfs ec -loadPolicy`"],"tags":["hdfs","erasure-coding","ec-policy","xml","schema-validation"],"backgroundTag":"config-validation-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}