apache/hadoop · error · IllegalArgumentException
Bad option value {} found for {}
Error message
Bad option value {} found for {} What it means
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.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/ECSchema.java:137
this.numDataUnits = numDataUnits;
this.numParityUnits = numParityUnits;
if (extraOptions == null) {
extraOptions = new HashMap<>();
}
// After some cleanup
this.extraOptions = Collections.unmodifiableMap(extraOptions);
}
private int extractIntOption(String optionKey, Map<String, String> options) {
int result = -1;
try {
if (options.containsKey(optionKey)) {
result = Integer.parseInt(options.get(optionKey));
if (result <= 0) {
throw new IllegalArgumentException("Bad option value " + result +
" found for " + optionKey);
}
}
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Option value " +
options.get(optionKey) + " for " + optionKey +
" is found. It should be an integer");
}
return result;
}
/**
* Get the codec name
* @return codec name
*/
public String getCodecName() {
return codecName;View on GitHub (pinned to 2add963021)
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
Example fix
// before
opts.put("codec", "rs");
opts.put("numDataUnits", "0"); // placeholder never set
opts.put("numParityUnits", "3");
new ECSchema(opts); // throws: Bad option value 0 found for numDataUnits
// after
opts.put("numDataUnits", "6"); Defensive patterns
Strategy: validation
Validate before calling
for (String k : new String[]{"numDataUnits", "numParityUnits"}) {
if (allOptions.containsKey(k)) {
int v = Integer.parseInt(allOptions.get(k).trim());
if (v <= 0) throw new IllegalArgumentException(k + " must be > 0, got " + v);
}
}
new ECSchema(allOptions); Try / catch
catch (IllegalArgumentException e) when message starts with 'Bad option value' -> map to a user-facing validation error naming the field.
Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- No schema options are provided
- No codec option is provided
- No good option for numDataUnits or numParityUnits found
- Option value {} for {} is found. It should be an integer
- Invalid inputs are found, all being null
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/f1fbe4ad8c19c668.
Report an issue: GitHub.