{"record":{"id":"aca5d1cf7297985d","repo":"apache/hadoop","slug":"bad-layoutversion-value-value-is-found-it-shoul","errorCode":null,"errorMessage":"Bad layoutVersion value {value} is found. It should be an integer","messagePattern":"Bad layoutVersion 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":144,"sourceCode":"\n    return policies;\n  }\n\n  /**\n   * Load layoutVersion from root element in the XML configuration file.\n   * @param root root element\n   * @return layout version\n   */\n  private int loadLayoutVersion(Element root) {\n    int layoutVersion;\n    Text text = (Text) root.getElementsByTagName(\"layoutversion\")\n        .item(0).getFirstChild();\n    if (text != null) {\n      String value = text.getData().trim();\n      try {\n        layoutVersion = Integer.parseInt(value);\n      } catch (NumberFormatException e) {\n        throw new IllegalArgumentException(\"Bad layoutVersion value \"\n            + value + \" is found. It should be an integer\");\n      }\n    } else {\n      throw new IllegalArgumentException(\"Value of <layoutVersion> is null\");\n    }\n\n    return layoutVersion;\n  }\n\n  /**\n   * Load schemas from root element in the XML configuration file.\n   * @param root root element\n   * @return EC schema map\n   */\n  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>();","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/util/ECPolicyLoader.java#L126-L162","documentation":"ECPolicyLoader.loadLayoutVersion() Integer.parseInt() on the trimmed text of <layoutversion> failed, so the value is not a plain integer (for example \"1.0\", \"one\", \"v1\"). The exception is an IllegalArgumentException carrying the offending value. Note that even a valid integer other than 1 is rejected later with a separate 'bad layoutversion value' RuntimeException.","triggerScenarios":"`hdfs ec -loadPolicy` on a file whose <layoutversion> holds a non-integer string, e.g. <layoutversion>1.0</layoutversion>, <layoutversion>v1</layoutversion>, or a decimal/float version.","commonSituations":"Copying fsimage layout version numbers (e.g. -66) from NameNode docs into the EC policy file, or writing a semantic version like 1.0 instead of the required literal 1.","solutions":["Set the element text to the plain integer 1: <layoutversion>1</layoutversion>","Remove any whitespace, quotes, or units from the element text (leading/trailing whitespace is trimmed, inner characters are not)","Re-run `hdfs ec -loadPolicy` and confirm the load reports the policies"],"exampleFix":"<!-- before -->\n<layoutversion>1.0</layoutversion>\n\n<!-- after -->\n<layoutversion>1</layoutversion>","handlingStrategy":"validation","validationCode":"String v = textOf(doc, \"layoutversion\").trim();\ntry {\n  Integer.parseInt(v);\n} catch (NumberFormatException e) {\n  throw new IllegalArgumentException(\"layoutversion '\" + v + \"' must be the integer 1\");\n}","typeGuard":null,"tryCatchPattern":"try { new ECPolicyLoader().loadPolicy(path); }\ncatch (IllegalArgumentException | RuntimeException e) {\n  LOG.error(\"Reject EC policy file {}: {}\", path, e.getMessage());\n}","preventionTips":["Treat layoutversion as the literal 1, not a version string","Never copy fsimage layout versions (negative numbers) into the EC policy file"],"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-22T20:17:22.307Z"}