{"record":{"id":"8f1e8946f1b6b04f","repo":"apache/hadoop","slug":"invalid-inputs-are-found-all-being-null","errorCode":null,"errorMessage":"Invalid inputs are found, all being null","messagePattern":"Invalid inputs are found, all being null","errorType":"exception","errorClass":"HadoopIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/coder/util/HHUtil.java","lineNumber":217,"sourceCode":"\n    return piggybacks;\n  }\n\n  /**\n   * Find the valid input from all the inputs.\n   *\n   * @param <T> Generics Type T.\n   * @param inputs input buffers to look for valid input\n   * @return the first valid input\n   */\n  public static <T> T findFirstValidInput(T[] inputs) {\n    for (T input : inputs) {\n      if (input != null) {\n        return input;\n      }\n    }\n\n    throw new HadoopIllegalArgumentException(\n            \"Invalid inputs are found, all being null\");\n  }\n}\n","sourceCodeStart":199,"sourceCodeEnd":221,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/coder/util/HHUtil.java#L199-L221","documentation":"HHUtil.findFirstValidInput scans an input array for the first non-null element and is used by Hitchhiker coding steps to infer the working buffer size; if every element is null it throws HadoopIllegalArgumentException(\"Invalid inputs are found, all being null\"). Decoding needs at least one readable input to proceed at all.","triggerScenarios":"Calling HH decode/encode paths with an inputs array whose elements are all null — typically every unit is missing/erased, or the caller represented upstream read failures as nulls and lost all of them. Also hit when an empty-capability buffer array (all slots null) is passed to CoderUtil/HHUtil.findFirstValidInput via raw coder state construction.","commonSituations":"More concurrent failures than the EC policy's parity can tolerate; datanode read errors swallowed and turned into null inputs; logic errors that null out inputs before decoding instead of passing erased indexes.","solutions":["Before decoding, verify at least numDataUnits inputs are non-null and readable; if not, the group genuinely cannot be recovered by EC alone","Propagate read failures as errors rather than silently replacing chunks with null","Pass erasure information via erasedIndexes/erasedMasks while keeping surviving units' buffers non-null"],"exampleFix":"// before\nfor (int i = 0; i < inputs.length; i++) {\n  if (readFailed[i]) inputs[i] = null; // may null out everything\n}\nstep.performCoding(inputChunks, outputChunks); // throws: all being null\n\n// after\nif (countNonNull(inputs) < numDataUnits) {\n  throw new IOException(\"Block group unrecoverable: fewer than \"\n      + numDataUnits + \" readable units\");\n}","handlingStrategy":"validation","validationCode":"int nonNull = 0;\nfor (ByteBuffer b : inputs) if (b != null) nonNull++;\nif (nonNull == 0) {\n  throw new IOException(\"Cannot decode: no readable input units\");\n}\nif (nonNull < decoder.getNumDataUnits()) {\n  throw new IOException(\"Unrecoverable: only \" + nonNull + \" of \"\n      + decoder.getNumDataUnits() + \" needed units readable\");\n}","typeGuard":"boolean hasEnoughValidInputs(Object[] inputs, int required) {\n  int n = 0;\n  for (Object in : inputs) if (in != null && ++n >= required) return true;\n  return false;\n}","tryCatchPattern":"try {\n  step.performCoding(in, out);\n} catch (HadoopIllegalArgumentException e) {\n  if (e.getMessage().contains(\"all being null\")) {\n    // treat as unrecoverable group: report, do not retry decode\n  }\n}","preventionTips":["Never silently substitute null for failed chunk reads; fail or retry the read first","Check readable-unit count against numDataUnits before every decode","Surface per-unit read errors so operators see which datanodes failed"],"tags":["erasure-coding","null-check","validation"],"backgroundTag":"null-input-argument","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}