{"record":{"id":"2e9f6a32eb1fbb31","repo":"apache/hadoop","slug":"no-codec-option-is-provided","errorCode":null,"errorMessage":"No codec option is provided","messagePattern":"No codec option is provided","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":76,"sourceCode":"  /*\n   * An erasure code can have its own specific advanced parameters, subject to\n   * itself to interpret these key-value settings.\n   */\n  private final Map<String, String> extraOptions;\n\n  /**\n   * Constructor with schema name and provided all options. Note the options may\n   * contain additional information for the erasure codec to interpret further.\n   * @param allOptions all schema options\n   */\n  public ECSchema(Map<String, String> allOptions) {\n    if (allOptions == null || allOptions.isEmpty()) {\n      throw new IllegalArgumentException(\"No schema options are provided\");\n    }\n\n    this.codecName = allOptions.get(CODEC_NAME_KEY);\n    if (codecName == null || codecName.isEmpty()) {\n      throw new IllegalArgumentException(\"No codec option is provided\");\n    }\n\n    int tmpNumDataUnits = extractIntOption(NUM_DATA_UNITS_KEY, allOptions);\n    int tmpNumParityUnits = extractIntOption(NUM_PARITY_UNITS_KEY, allOptions);\n    if (tmpNumDataUnits < 0 || tmpNumParityUnits < 0) {\n      throw new IllegalArgumentException(\n          \"No good option for numDataUnits or numParityUnits found \");\n    }\n    this.numDataUnits = tmpNumDataUnits;\n    this.numParityUnits = tmpNumParityUnits;\n\n    allOptions.remove(CODEC_NAME_KEY);\n    allOptions.remove(NUM_DATA_UNITS_KEY);\n    allOptions.remove(NUM_PARITY_UNITS_KEY);\n    // After some cleanup\n    this.extraOptions = Collections.unmodifiableMap(allOptions);\n  }\n","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/ECSchema.java#L58-L94","documentation":"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.","triggerScenarios":"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 \"\".","commonSituations":"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.","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"],"exampleFix":"// before\nMap<String, String> opts = new HashMap<>();\nopts.put(\"codecname\", \"rs\"); // wrong key\nopts.put(\"numDataUnits\", \"6\");\nopts.put(\"numParityUnits\", \"3\");\nnew ECSchema(opts); // throws: no \"codec\" key\n\n// after\nopts.put(ECSchema.CODEC_NAME_KEY, \"rs\"); // exact key \"codec\"","handlingStrategy":"validation","validationCode":"String codec = allOptions.get(ECSchema.CODEC_NAME_KEY); // key \"codec\"\nif (codec == null || codec.trim().isEmpty()) {\n  throw new IllegalArgumentException(\"EC schema is missing the 'codec' option\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  new ECSchema(allOptions);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"No codec option\")) {\n    // fix source: map key must be exactly \"codec\"\n  }\n  throw e;\n}","preventionTips":["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"],"tags":["erasure-coding","schema","validation","hadoop-common"],"backgroundTag":"missing-required-field","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}