{"record":{"id":"457a8e9d16ab37b3","repo":"apache/hadoop","slug":"invalid-inputs-length","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/HHXORErasureDecodingStep.java","lineNumber":90,"sourceCode":"    }\n\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 = rsRawDecoder.getNumDataUnits();\n    final int numParityUnits = rsRawDecoder.getNumParityUnits();\n    final int numTotalUnits = numDataUnits + numParityUnits;\n    final int subPacketSize = getSubPacketSize();\n\n    ByteBuffer fisrtValidInput = HHUtil.findFirstValidInput(inputs);\n    final int bufSize = fisrtValidInput.remaining();\n\n    if (inputs.length != numTotalUnits * getSubPacketSize()) {\n      throw new IllegalArgumentException(\"Invalid inputs length\");\n    }\n\n    if (outputs.length != erasedIndexes.length * getSubPacketSize()) {\n      throw new IllegalArgumentException(\"Invalid outputs length\");\n    }\n\n    // notes:inputs length = numDataUnits * subPacketizationSize\n    // first numDataUnits length is first sub-stripe,\n    // second numDataUnits length is second sub-stripe\n    ByteBuffer[][] newIn = new ByteBuffer[subPacketSize][numTotalUnits];\n    for (int i = 0; i < subPacketSize; ++i) {\n      for (int j = 0; j < numTotalUnits; ++j) {\n        newIn[i][j] = inputs[i * numTotalUnits + j];\n      }\n    }\n\n    ByteBuffer[][] newOut = new ByteBuffer[subPacketSize][erasedIndexes.length];\n    for (int i = 0; i < subPacketSize; ++i) {","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/coder/HHXORErasureDecodingStep.java#L72-L108","documentation":"HHXORErasureDecodingStep.performCoding (the Hitchhiker-XOR decode step) validates that the input buffer array is sub-packetized: inputs.length must equal (numDataUnits + numParityUnits) * subPacketSize, where subPacketSize is 2 (HHErasureCodingStep.SUB_PACKET_SIZE). Unlike plain RS decoding, each logical unit contributes two buffers (two sub-stripes), so a flat RS-style array is rejected with IllegalArgumentException.","triggerScenarios":"Invoking HHXORErasureDecodingStep.performCoding (directly or through the HHXORErasureCodec decoder on a hhxor EC policy) with inputs sized numTotalUnits instead of numTotalUnits * 2, or with buffers allocated from different ErasureCoderOptions than the RS raw decoder held by the step.","commonSituations":"Porting stripe-level code written for the RS codec to the hhxor codec without doubling buffer counts; constructing the decoding step by hand instead of obtaining it from HHXORErasureCodec; unit-count mismatches between the coder options and buffer allocation.","solutions":["Allocate inputs as (numDataUnits + numParityUnits) * 2 buffers (subPacketSize 2), laid out as consecutive sub-stripes","Ensure the ErasureCoderOptions used to create the underlying RS decoder match the counts used to size the arrays","Obtain encoding/decoding steps via HHXORErasureCodec.createEncoder()/createDecoder() rather than instantiating the step directly"],"exampleFix":"// before\nint total = numDataUnits + numParityUnits;\nByteBuffer[] inputs = new ByteBuffer[total]; // RS-style, too short\nstep.performCoding(inputChunks, outputChunks); // throws\n\n// after\nint subPacket = 2;\nByteBuffer[] inputs = new ByteBuffer[total * subPacket]; // one buffer per sub-stripe per unit","handlingStrategy":"validation","validationCode":"int sub = 2; // HHErasureCodingStep SUB_PACKET_SIZE\nint expected = (rsDecoder.getNumDataUnits() + rsDecoder.getNumParityUnits()) * sub;\nif (inputBuffers.length != expected) {\n  throw new IllegalArgumentException(\"HHXOR decode needs \" + expected\n      + \" inputs (\" + (expected / sub) + \" units x \" + sub + \" sub-packets)\");\n}\nstep.performCoding(inputChunks, outputChunks);","typeGuard":null,"tryCatchPattern":"try {\n  step.performCoding(in, out);\n} catch (IllegalArgumentException e) {\n  // length contract violated; recompute allocation from coder options and retry once\n}","preventionTips":["Never share allocation helpers between RS and hhxor without a subPacketSize factor","Derive buffer counts from the coder's own getNumDataUnits()/getNumParityUnits() plus subPacketSize","Prefer the codec-level API (HHXORErasureCodec) which enforces layout consistently"],"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"}