{"record":{"id":"b2da41354cdd2d11","repo":"apache/hadoop","slug":"invalid-inputs-length-b2da41","errorCode":null,"errorMessage":"Invalid inputs length","messagePattern":"Invalid inputs length","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/coder/HHXORErasureEncodingStep.java","lineNumber":75,"sourceCode":"  }\n\n  @Override\n  public void performCoding(ECChunk[] inputChunks, ECChunk[] outputChunks)\n      throws IOException {\n    ByteBuffer[] inputBuffers = ECChunk.toBuffers(inputChunks);\n    ByteBuffer[] outputBuffers = ECChunk.toBuffers(outputChunks);\n    performCoding(inputBuffers, outputBuffers);\n  }\n\n  private void performCoding(ByteBuffer[] inputs, ByteBuffer[] outputs)\n      throws IOException {\n    final int numDataUnits = this.rsRawEncoder.getNumDataUnits();\n    final int numParityUnits = this.rsRawEncoder.getNumParityUnits();\n    final int subSPacketSize = getSubPacketSize();\n\n    // inputs length = numDataUnits * subPacketSize\n    if (inputs.length != numDataUnits * subSPacketSize) {\n      throw new IllegalArgumentException(\"Invalid inputs length\");\n    }\n\n    if (outputs.length != numParityUnits * subSPacketSize) {\n      throw new IllegalArgumentException(\"Invalid outputs length\");\n    }\n\n    // first numDataUnits length is first sub-stripe,\n    // second numDataUnits length is second sub-stripe\n    ByteBuffer[][] hhInputs = new ByteBuffer[subSPacketSize][numDataUnits];\n    for (int i = 0; i < subSPacketSize; ++i) {\n      for (int j = 0; j < numDataUnits; ++j) {\n        hhInputs[i][j] = inputs[i * numDataUnits + j];\n      }\n    }\n\n    ByteBuffer[][] hhOutputs = new ByteBuffer[subSPacketSize][numParityUnits];\n    for (int i = 0; i < subSPacketSize; ++i) {\n      for (int j = 0; j < numParityUnits; ++j) {","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/coder/HHXORErasureEncodingStep.java#L57-L93","documentation":"HHXORErasureEncodingStep.performCoding validates that the encode input array is sub-packetized: inputs.length must equal numDataUnits * subPacketSize, with subPacketSize 2 for Hitchhiker. Each data unit must be presented as two buffers (the two sub-stripes HH piggybacks on); a flat array of numDataUnits buffers is an IllegalArgumentException.","triggerScenarios":"Running the hhxor encoding step (directly or via HHXORErasureCodec encoder under a hhxor EC policy) with inputs allocated as numDataUnits single buffers, or with arrays sized from options whose unit counts differ from the RS raw encoder inside the step.","commonSituations":"Code written against the plain RS raw coder reused for hhxor; partial migration of a striping writer to sub-packetization; encoder created with different ErasureCoderOptions than the buffer layout.","solutions":["Allocate inputs as numDataUnits * 2 buffers (subPacketSize 2), filling both sub-stripes per data unit","Confirm outputs are likewise sized numParityUnits * 2 to avoid failing the next check","Create the encoder through CodecUtil/HHXORErasureCodec so options and layout stay consistent"],"exampleFix":"// before\nByteBuffer[] inputs = new ByteBuffer[numDataUnits]; // flat RS layout\nstep.performCoding(inputBuffers, outputBuffers); // throws\n\n// after\nint subPacket = 2;\nByteBuffer[] inputs = new ByteBuffer[numDataUnits * subPacket];","handlingStrategy":"validation","validationCode":"int sub = 2;\nif (inputBuffers.length != encoder.getNumDataUnits() * sub) {\n  throw new IllegalArgumentException(\"HHXOR encode needs \"\n      + encoder.getNumDataUnits() * sub + \" input buffers\");\n}\nencoder or step.performCoding(...);","typeGuard":null,"tryCatchPattern":"try {\n  step.performCoding(inputs, outputs);\n} catch (IllegalArgumentException e) {\n  // re-allocate inputs as numDataUnits * 2 and rebuild the step\n}","preventionTips":["Compute encode input allocation as numDataUnits * subPacketSize, not numDataUnits","Keep the ErasureCoderOptions used for allocation and for encoder creation identical","Test codec-specific buffer shapes in an integration test per supported codec"],"tags":["erasure-coding","hitchhiker","hhxor","buffer-mismatch"],"backgroundTag":"buffer-length-mismatch","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}