apache/hadoop · error · IllegalArgumentException

Bad layoutVersion value {value} is found. It should be an in

Error message

Bad layoutVersion value {value} is found. It should be an integer

What it means

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.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/util/ECPolicyLoader.java:144

    return policies;
  }

  /**
   * Load layoutVersion from root element in the XML configuration file.
   * @param root root element
   * @return layout version
   */
  private int loadLayoutVersion(Element root) {
    int layoutVersion;
    Text text = (Text) root.getElementsByTagName("layoutversion")
        .item(0).getFirstChild();
    if (text != null) {
      String value = text.getData().trim();
      try {
        layoutVersion = Integer.parseInt(value);
      } catch (NumberFormatException e) {
        throw new IllegalArgumentException("Bad layoutVersion value "
            + value + " is found. It should be an integer");
      }
    } else {
      throw new IllegalArgumentException("Value of <layoutVersion> is null");
    }

    return layoutVersion;
  }

  /**
   * Load schemas from root element in the XML configuration file.
   * @param root root element
   * @return EC schema map
   */
  private Map<String, ECSchema> loadSchemas(Element root) {
    NodeList elements = root.getElementsByTagName("schemas")
        .item(0).getChildNodes();
    Map<String, ECSchema> schemas = new HashMap<String, ECSchema>();

View on GitHub (pinned to 2add963021)

Solutions

  1. Set the element text to the plain integer 1: <layoutversion>1</layoutversion>
  2. Remove any whitespace, quotes, or units from the element text (leading/trailing whitespace is trimmed, inner characters are not)
  3. Re-run `hdfs ec -loadPolicy` and confirm the load reports the policies

Example fix

<!-- before -->
<layoutversion>1.0</layoutversion>

<!-- after -->
<layoutversion>1</layoutversion>
Defensive patterns

Strategy: validation

Validate before calling

String v = textOf(doc, "layoutversion").trim();
try {
  Integer.parseInt(v);
} catch (NumberFormatException e) {
  throw new IllegalArgumentException("layoutversion '" + v + "' must be the integer 1");
}

Try / catch

try { new ECPolicyLoader().loadPolicy(path); }
catch (IllegalArgumentException | RuntimeException e) {
  LOG.error("Reject EC policy file {}: {}", path, e.getMessage());
}

Prevention

When it happens

Trigger: `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.

Common situations: 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.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/aca5d1cf7297985d. Report an issue: GitHub.