{"record":{"id":"81f9f91393255ea9","repo":"apache/hadoop","slug":"option-value-for-is-found-it-should-be-an-i","errorCode":null,"errorMessage":"Option value {} for {} is found. It should be an integer","messagePattern":"Option value (.+?) for (.+?) is found\\. It should be an integer","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/ECSchema.java","lineNumber":142,"sourceCode":"    }\n\n    // After some cleanup\n    this.extraOptions = Collections.unmodifiableMap(extraOptions);\n  }\n\n  private int extractIntOption(String optionKey, Map<String, String> options) {\n    int result = -1;\n\n    try {\n      if (options.containsKey(optionKey)) {\n        result = Integer.parseInt(options.get(optionKey));\n        if (result <= 0) {\n          throw new IllegalArgumentException(\"Bad option value \" + result +\n              \" found for \" + optionKey);\n        }\n      }\n    } catch (NumberFormatException e) {\n      throw new IllegalArgumentException(\"Option value \" +\n          options.get(optionKey) + \" for \" + optionKey +\n          \" is found. It should be an integer\");\n    }\n\n    return result;\n  }\n\n  /**\n   * Get the codec name\n   * @return codec name\n   */\n  public String getCodecName() {\n    return codecName;\n  }\n\n  /**\n   * Get extra options specific to an erasure code.\n   * @return extra options","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/ECSchema.java#L124-L160","documentation":"ECSchema.extractIntOption wraps Integer.parseInt; when a \"numDataUnits\" or \"numParityUnits\" value is not a parseable integer (fractional string, letters, empty, embedded whitespace) a NumberFormatException is converted into this IllegalArgumentException naming the offending value and key. The schema never gets built because the counts cannot be interpreted.","triggerScenarios":"new ECSchema(map) with values like \"6.0\", \"3.5\", \"six\", \"\" or \" 6\"; JSON/XML numbers serialized as floats or with locale-specific formatting; empty <numDataUnits></numDataUnits> elements.","commonSituations":"Schema options round-tripped through systems that reformat numbers (floats, thousands separators); hand-edited policy files; whitespace introduced by pretty-printed XML.","solutions":["Use plain integer strings (\"6\", \"3\") for both unit-count keys","Trim values and reject/fix fractional formats before constructing the schema","Pre-validate with Integer.parseInt in your own code to fail with a clearer message pointing at the source field"],"exampleFix":"// before\nopts.put(\"numDataUnits\", \"6.0\"); // float string\nnew ECSchema(opts); // throws: It should be an integer\n\n// after\nopts.put(\"numDataUnits\", Integer.toString(6));","handlingStrategy":"validation","validationCode":"for (String k : new String[]{\"numDataUnits\", \"numParityUnits\"}) {\n  String v = allOptions.get(k);\n  if (v != null) {\n    Integer.parseInt(v.trim()); // throws early with your own context\n  }\n}\nnew ECSchema(allOptions);","typeGuard":null,"tryCatchPattern":"try {\n  new ECSchema(allOptions);\n} catch (IllegalArgumentException e) {\n  Throwable cause = e; // NumberFormatException context is embedded in message\n  throw new IllegalArgumentException(\"Non-integer EC schema option: \"\n      + allOptions, e);\n}","preventionTips":["Emit integers with Integer.toString when generating policy files; never serialize floats for unit counts","Trim whitespace from values parsed from pretty-printed XML","Reject values matching non-digit patterns at config load time"],"tags":["erasure-coding","schema","validation","numberformatexception"],"backgroundTag":"number-format-exception","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}