apache/hadoop · error · IllegalArgumentException
No good option for numDataUnits or numParityUnits found
Error message
No good option for numDataUnits or numParityUnits found
What it means
ECSchema reads "numDataUnits" and "numParityUnits" via extractIntOption, which returns -1 when a key is absent; the constructor then rejects any negative count with IllegalArgumentException. This error therefore means one or both unit-count keys are missing from the options map (not merely invalid — invalid values produce different messages).
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/ECSchema.java:82
/**
* Constructor with schema name and provided all options. Note the options may
* contain additional information for the erasure codec to interpret further.
* @param allOptions all schema options
*/
public ECSchema(Map<String, String> allOptions) {
if (allOptions == null || allOptions.isEmpty()) {
throw new IllegalArgumentException("No schema options are provided");
}
this.codecName = allOptions.get(CODEC_NAME_KEY);
if (codecName == null || codecName.isEmpty()) {
throw new IllegalArgumentException("No codec option is provided");
}
int tmpNumDataUnits = extractIntOption(NUM_DATA_UNITS_KEY, allOptions);
int tmpNumParityUnits = extractIntOption(NUM_PARITY_UNITS_KEY, allOptions);
if (tmpNumDataUnits < 0 || tmpNumParityUnits < 0) {
throw new IllegalArgumentException(
"No good option for numDataUnits or numParityUnits found ");
}
this.numDataUnits = tmpNumDataUnits;
this.numParityUnits = tmpNumParityUnits;
allOptions.remove(CODEC_NAME_KEY);
allOptions.remove(NUM_DATA_UNITS_KEY);
allOptions.remove(NUM_PARITY_UNITS_KEY);
// After some cleanup
this.extraOptions = Collections.unmodifiableMap(allOptions);
}
/**
* Constructor with key parameters provided.
* @param codecName codec name
* @param numDataUnits number of data units used in the schema
* @param numParityUnits number os parity units used in the schema
*/View on GitHub (pinned to 2add963021)
Solutions
- Add both "numDataUnits" and "numParityUnits" keys with positive integer string values
- Check exact key spelling/case (they are case-sensitive literals of ECSchema.NUM_DATA_UNITS_KEY / NUM_PARITY_UNITS_KEY)
- Use new ECSchema(codecName, numDataUnits, numParityUnits) for programmatic construction, or start from ErasureCodeConstants.RS_6_3_SCHEMA-style predefined schemas
Example fix
// before
Map<String, String> opts = new HashMap<>();
opts.put("codec", "rs");
opts.put("numDataUnits", "6");
// numParityUnits forgotten
new ECSchema(opts); // throws
// after
opts.put("numParityUnits", "3"); Defensive patterns
Strategy: validation
Validate before calling
if (!allOptions.containsKey(ECSchema.NUM_DATA_UNITS_KEY)
|| !allOptions.containsKey(ECSchema.NUM_PARITY_UNITS_KEY)) {
throw new IllegalArgumentException(
"EC schema needs numDataUnits and numParityUnits options");
}
new ECSchema(allOptions); Try / catch
try {
schema = new ECSchema(allOptions);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Malformed EC schema options: "
+ allOptions + ": " + e.getMessage(), e);
} Prevention
- Use ECSchema.NUM_DATA_UNITS_KEY / NUM_PARITY_UNITS_KEY constants to avoid casing mistakes
- Prefer the typed convenience constructor ECSchema(codec, numData, numParity)
- Unit-test policy deserialization with sample files to catch dropped keys early
When it happens
Trigger: Calling new ECSchema(map) where map has a valid "codec" entry but is missing "numDataUnits" and/or "numParityUnits"; keys misspelled as "numdataunits" or "dataUnits" so the lookups never find them.
Common situations: Policy or JSON files with inconsistently cased unit-count keys; partial maps built by merging configurations where the counts were dropped; schemas assembled by hand instead of via the convenience constructor.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- No schema options are provided
- No codec option is provided
- Bad option value {} found for {}
- Option value {} for {} is found. It should be an integer
- Wrong length: {digest.length}
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/f571a4de91929403.
Report an issue: GitHub.