{"record":{"id":"767895286b1c7926","repo":"apache/iceberg","slug":"buffer-size-of-d-is-larger-than-requested-size-of","errorCode":null,"errorMessage":"Buffer size of %d is larger than requested size of %d","messagePattern":"Buffer size of (.+?) is larger than requested size of (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"arrow/src/main/java/org/apache/iceberg/arrow/vectorized/parquet/DecimalVectorUtil.java","lineNumber":64,"sourceCode":"  @VisibleForTesting\n  static byte[] padBigEndianBytes(byte[] bigEndianBytes, int newLength) {\n    if (bigEndianBytes.length == newLength) {\n      return bigEndianBytes;\n    } else if (bigEndianBytes.length < newLength) {\n      byte[] result = new byte[newLength];\n      if (bigEndianBytes.length == 0) {\n        return result;\n      }\n\n      int start = newLength - bigEndianBytes.length;\n      if (bigEndianBytes[0] < 0) {\n        Arrays.fill(result, 0, start, (byte) 0xFF);\n      }\n      System.arraycopy(bigEndianBytes, 0, result, start, bigEndianBytes.length);\n\n      return result;\n    }\n    throw new IllegalArgumentException(\n        String.format(\n            Locale.ROOT,\n            \"Buffer size of %d is larger than requested size of %d\",\n            bigEndianBytes.length,\n            newLength));\n  }\n}\n","sourceCodeStart":46,"sourceCodeEnd":72,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/arrow/src/main/java/org/apache/iceberg/arrow/vectorized/parquet/DecimalVectorUtil.java#L46-L72","documentation":"padBigEndianBytes pads a decimal's big-endian byte buffer to a requested length; if the source buffer is already longer than the requested new length, padding is impossible and it throws IllegalArgumentException. This guards against calling with a target size smaller than the input.","triggerScenarios":"Calling DecimalVectorUtil.padBigEndianBytes(bytes, newLength) where bytes.length > newLength.","commonSituations":"Reading DECIMAL columns whose precision implies more bytes than the target Arrow/Parquet buffer width, typically a bug in width computation for high-precision decimals.","solutions":["Compute the target length from the column's actual precision (ceil((precision+1)/... bits/8)) rather than a fixed size.","Pass newLength >= bigEndianBytes.length.","Verify the Parquet decimal precision against the expected Arrow type; fix the schema mapping."],"exampleFix":"// before\nbyte[] padded = DecimalVectorUtil.padBigEndianBytes(bytes, 8); // bytes.length == 16\n// after\nint target = Math.max(8, bytes.length);\nbyte[] padded = DecimalVectorUtil.padBigEndianBytes(bytes, target);","handlingStrategy":"validation","validationCode":"if (bytes.length > targetLength) {\n  throw new IllegalArgumentException(\"buffer \" + bytes.length + \" exceeds target \" + targetLength);\n}\nbyte[] padded = DecimalVectorUtil.padBigEndianBytes(bytes, targetLength);","typeGuard":null,"tryCatchPattern":"// catch (IllegalArgumentException e) {\n//   if (e.getMessage().contains(\"larger than requested size\")) { recomputeTargetWidth(); }\n//   else throw e;\n// }","preventionTips":["Derive buffer width from decimal precision, never hardcode.","Assert newLength >= bytes.length before calling.","Test decimal mapping for high-precision columns."],"tags":["parquet","decimal","vectorized-reader","argument-validation"],"backgroundTag":"value-out-of-range","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}