{"record":{"id":"f571a4de91929403","repo":"apache/hadoop","slug":"no-good-option-for-numdataunits-or-numparityunits","errorCode":null,"errorMessage":"No good option for numDataUnits or numParityUnits found ","messagePattern":"No good option for numDataUnits or numParityUnits found ","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":82,"sourceCode":"  /**\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\n  /**\n   * Constructor with key parameters provided.\n   * @param codecName codec name\n   * @param numDataUnits number of data units used in the schema\n   * @param numParityUnits number os parity units used in the schema\n   */","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/ECSchema.java#L64-L100","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nMap<String, String> opts = new HashMap<>();\nopts.put(\"codec\", \"rs\");\nopts.put(\"numDataUnits\", \"6\");\n// numParityUnits forgotten\nnew ECSchema(opts); // throws\n\n// after\nopts.put(\"numParityUnits\", \"3\");","handlingStrategy":"validation","validationCode":"if (!allOptions.containsKey(ECSchema.NUM_DATA_UNITS_KEY)\n    || !allOptions.containsKey(ECSchema.NUM_PARITY_UNITS_KEY)) {\n  throw new IllegalArgumentException(\n      \"EC schema needs numDataUnits and numParityUnits options\");\n}\nnew ECSchema(allOptions);","typeGuard":null,"tryCatchPattern":"try {\n  schema = new ECSchema(allOptions);\n} catch (IllegalArgumentException e) {\n  throw new IllegalArgumentException(\"Malformed EC schema options: \"\n      + allOptions + \": \" + e.getMessage(), e);\n}","preventionTips":["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"],"tags":["erasure-coding","schema","validation","hadoop-common"],"backgroundTag":"schema-validation-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}