{"record":{"id":"f1fbe4ad8c19c668","repo":"apache/hadoop","slug":"bad-option-value-found-for","errorCode":null,"errorMessage":"Bad option value {} found for {}","messagePattern":"Bad option value (.+?) found for (.+?)","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":137,"sourceCode":"    this.numDataUnits = numDataUnits;\n    this.numParityUnits = numParityUnits;\n\n    if (extraOptions == null) {\n      extraOptions = new HashMap<>();\n    }\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;","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/ECSchema.java#L119-L155","documentation":"Inside ECSchema.extractIntOption, a unit-count value that parses as an integer but is <= 0 (zero or negative) throws IllegalArgumentException naming the value and the key. Erasure schemas need at least one data unit and usually at least one parity unit, so non-positive counts are meaningless and rejected at construction.","triggerScenarios":"new ECSchema(map) with \"numDataUnits\" = \"0\" or a negative number like \"-1\"; defaults or placeholders (\"0\") that were never replaced by real values; arithmetic that computed a zero count before building the map.","commonSituations":"Template policy files with 0 placeholders; code that derives counts from ratios or subtraction and can produce 0; misconfigured generated XML where a missing element was defaulted to 0.","solutions":["Set both unit counts to positive integers (numDataUnits >= 1, numParityUnits >= 1)","Trace where the zero/negative value came from if the map is generated (defaults, arithmetic, config placeholders)","Validate counts (> 0, and parity <= a sane maximum for the codec) before constructing the schema"],"exampleFix":"// before\nopts.put(\"codec\", \"rs\");\nopts.put(\"numDataUnits\", \"0\"); // placeholder never set\nopts.put(\"numParityUnits\", \"3\");\nnew ECSchema(opts); // throws: Bad option value 0 found for numDataUnits\n\n// after\nopts.put(\"numDataUnits\", \"6\");","handlingStrategy":"validation","validationCode":"for (String k : new String[]{\"numDataUnits\", \"numParityUnits\"}) {\n  if (allOptions.containsKey(k)) {\n    int v = Integer.parseInt(allOptions.get(k).trim());\n    if (v <= 0) throw new IllegalArgumentException(k + \" must be > 0, got \" + v);\n  }\n}\nnew ECSchema(allOptions);","typeGuard":null,"tryCatchPattern":"catch (IllegalArgumentException e) when message starts with 'Bad option value' -> map to a user-facing validation error naming the field.","preventionTips":["Validate unit counts as positive integers in your policy-editing UI or config loader before they reach ECSchema","Reject placeholder values like 0 at ingestion time","Cross-check parity counts against codec limits (e.g., RS parity typically <= 6) when authoring policies"],"tags":["erasure-coding","schema","validation","invalid-value"],"backgroundTag":"invalid-config-value","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}