apache/hadoop · error · IllegalArgumentException
No codec option is provided
Error message
No codec option is provided
What it means
The options map passed to new ECSchema(Map) is non-empty but has no usable value under ECSchema.CODEC_NAME_KEY, which is the literal string "codec" (null or empty string value). Without a codec name the schema cannot be mapped to a raw coder factory, so construction fails with IllegalArgumentException.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/ECSchema.java:76
/*
* An erasure code can have its own specific advanced parameters, subject to
* itself to interpret these key-value settings.
*/
private final Map<String, String> extraOptions;
/**
* 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);
}
View on GitHub (pinned to 2add963021)
Solutions
- Put the codec name under the exact key "codec" (ECSchema.CODEC_NAME_KEY) with a non-empty value such as "rs"
- Check for misspelled or differently-cased variants of the key ("codecname", "codecName") in the source map or policy file
- Trim whitespace from values read from XML/JSON before constructing the schema
Example fix
// before
Map<String, String> opts = new HashMap<>();
opts.put("codecname", "rs"); // wrong key
opts.put("numDataUnits", "6");
opts.put("numParityUnits", "3");
new ECSchema(opts); // throws: no "codec" key
// after
opts.put(ECSchema.CODEC_NAME_KEY, "rs"); // exact key "codec" Defensive patterns
Strategy: validation
Validate before calling
String codec = allOptions.get(ECSchema.CODEC_NAME_KEY); // key "codec"
if (codec == null || codec.trim().isEmpty()) {
throw new IllegalArgumentException("EC schema is missing the 'codec' option");
} Try / catch
try {
new ECSchema(allOptions);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("No codec option")) {
// fix source: map key must be exactly "codec"
}
throw e;
} Prevention
- Reference ECSchema.CODEC_NAME_KEY instead of hardcoding key names when building option maps
- Beware formats that use 'codecname' — translate to the ECSchema key 'codec' explicitly
- Trim values from XML/JSON before populating the map
When it happens
Trigger: Passing a map that contains only "numDataUnits"/"numParityUnits"; using a differently spelled key such as "codecname" or "codecName" instead of the exact key "codec"; an empty <codec> element in a policy file that deserializes to "".
Common situations: Key-naming mismatch between external policy formats (which often say "codecname") and the ECSchema map key "codec"; whitespace-only or empty codec values from hand-edited XML; maps assembled by code that assumed different key names.
Understand the failure class
Background: "Missing required field" and "field is required" errors: why libraries reject payloads that omit mandatory fields — this error's family across 20 libraries.
Related errors
- No schema options are provided
- No good option for numDataUnits or numParityUnits found
- 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/2e9f6a32eb1fbb31.
Report an issue: GitHub.