{"record":{"id":"39763148672fa41a","repo":"apache/hadoop","slug":"bad-ec-policy-cellsize-value-value-is-found-it","errorCode":null,"errorMessage":"Bad EC policy cellsize value {value} is found. It should be an integer","messagePattern":"Bad EC policy cellsize value (.+?) is found\\. It should be an integer","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":306,"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\n        // Get the nonnull text value.\n        Text text = (Text) field.getFirstChild();\n        if (text != null) {\n          if (!text.isElementContentWhitespace()) {\n            String value = text.getData().trim();\n            if (\"schema\".equals(tagName)) {\n              schema = schemas.get(value);\n            } else if (\"cellsize\".equals(tagName)) {\n              try {\n                cellSize = Integer.parseInt(value);\n              } 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\");","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/util/ECPolicyLoader.java#L288-L324","documentation":"ECPolicyLoader.loadPolicy() Integer.parseInt() on the text of a policy's <cellsize> element failed, so the cell size is not a plain integer. Thrown as IllegalArgumentException with the offending value. The cell size is the striping cell size in bytes (typical value 1MB = 1048576); memory-style units like '1MB' or '1m' are not accepted.","triggerScenarios":"`hdfs ec -loadPolicy` where a policy contains <cellsize>1MB</cellsize>, <cellsize>1024.0</cellsize>, or any non-integer text. Note the value must also be > 0 or the later 'Bad policy is found' check fails.","commonSituations":"Writing human-readable sizes (64k, 1MB) as with other Hadoop configs that accept size suffixes; the EC policy XML accepts raw bytes only.","solutions":["Use a plain integer byte count: <cellsize>1048576</cellsize> for 1MB","Remove units, commas, and decimal points from the value","Keep the value positive; 0 or negative passes the parse but fails the final policy validation"],"exampleFix":"<!-- before -->\n<cellsize>1MB</cellsize>\n\n<!-- after -->\n<cellsize>1048576</cellsize>","handlingStrategy":"validation","validationCode":"String cs = textOf(policyElement, \"cellsize\").trim();\ntry {\n  if (Integer.parseInt(cs) <= 0) throw new IllegalArgumentException(\"cellsize must be > 0\");\n} catch (NumberFormatException e) {\n  throw new IllegalArgumentException(\"cellsize '\" + cs + \"' must be a plain integer byte count (e.g. 1048576)\");\n}","typeGuard":null,"tryCatchPattern":"try { new ECPolicyLoader().loadPolicy(path); }\ncatch (IllegalArgumentException e) {\n  LOG.error(\"EC policy file {} rejected: {}\", path, e.getMessage());\n}","preventionTips":["Never use size suffixes (k/MB) in the EC policy XML — bytes only","Standard cell size is 1048576; deviate only with reason"],"tags":["hdfs","erasure-coding","ec-policy","xml","number-format"],"backgroundTag":"invalid-config-value","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}