{"record":{"id":"699fd15529126d72","repo":"apache/hadoop","slug":"invalid-outputs-length-699fd1","errorCode":null,"errorMessage":"Invalid outputs length","messagePattern":"Invalid outputs 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":79,"sourceCode":"      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) {\n        hhOutputs[i][j] = outputs[i * numParityUnits + j];\n      }\n    }\n","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/erasurecode/coder/HHXORErasureEncodingStep.java#L61-L97","documentation":"The HHXOR (Hitchhiker-XOR) encoding step requires outputs.length == numParityUnits * subPacketSize (subPacketSize 2): parity is produced per sub-stripe, so each parity unit yields two output buffers. A single-buffer-per-parity-unit array throws IllegalArgumentException before any coding runs.","triggerScenarios":"Calling the hhxor encoding step's performCoding with outputs sized numParityUnits instead of numParityUnits * 2, or mixing an RS-shaped output allocation into an hhxor pipeline.","commonSituations":"Shared parity-allocation helpers written for RS reused under a hhxor policy; refactoring an encoder pipeline where only input sizing was updated.","solutions":["Allocate outputs as numParityUnits * 2 buffers (subPacketSize 2)","Update any shared allocation helpers to take the codec's sub-packet size into account","Drive encoding via HHXORErasureCodec so the buffer contract is honored end to end"],"exampleFix":"// before\nByteBuffer[] outputs = new ByteBuffer[numParityUnits];\n// throws: Invalid outputs length\n\n// after\nByteBuffer[] outputs = new ByteBuffer[numParityUnits * 2]; // subPacketSize 2","handlingStrategy":"validation","validationCode":"int sub = 2;\nif (outputBuffers.length != encoder.getNumParityUnits() * sub) {\n  throw new IllegalArgumentException(\"HHXOR encode needs \"\n      + encoder.getNumParityUnits() * sub + \" output buffers\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  step.performCoding(inputs, outputs);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"outputs length\")) resizeOutputs();\n}","preventionTips":["Allocate parity outputs as numParityUnits * subPacketSize for hhxor","Make allocation helpers take the codec name and sub-packet factor as parameters","Avoid copy-pasting RS encode scaffolding into hhxor paths"],"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"}