{"record":{"id":"b0c4f7c833736678","repo":"apache/iceberg","slug":"can-not-decode-bitwidth-in-block-header","errorCode":null,"errorMessage":"Can not decode bitwidth in block header","messagePattern":"Can not decode bitwidth in block header","errorType":"exception","errorClass":"ParquetDecodingException","httpStatus":null,"severity":"error","filePath":"arrow/src/main/java/org/apache/iceberg/arrow/vectorized/parquet/VectorizedDeltaEncodedValuesReader.java","lineNumber":248,"sourceCode":"      ByteBuffer buffer = inputStream.slice(packer.getBitWidth());\n      if (buffer.hasArray()) {\n        packer.unpack8Values(\n            buffer.array(), buffer.arrayOffset() + buffer.position(), unpackedValuesBuffer, j);\n      } else {\n        packer.unpack8Values(buffer, buffer.position(), unpackedValuesBuffer, j);\n      }\n    }\n    remainingInMiniBlock = miniBlockSizeInValues;\n    currentMiniBlock++;\n  }\n\n  // From org.apache.parquet.column.values.delta.DeltaBinaryPackingValuesReader\n  private void readBitWidthsForMiniBlocks() {\n    for (int i = 0; i < miniBlocksPerBlock; i++) {\n      try {\n        bitWidths[i] = BytesUtils.readIntLittleEndianOnOneByte(inputStream);\n      } catch (IOException e) {\n        throw new ParquetDecodingException(\"Can not decode bitwidth in block header\", e);\n      }\n    }\n  }\n\n  /** A functional interface to write long values to into a FieldVector */\n  @FunctionalInterface\n  interface IntegerOutputWriter {\n\n    /**\n     * A functional interface that can be used to write a long value to a specified row in a\n     * FieldVector\n     *\n     * @param vec a FieldVector to write the value into\n     * @param index The offset to write to\n     * @param val value to write\n     */\n    void write(FieldVector vec, long index, long val);\n  }","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/arrow/src/main/java/org/apache/iceberg/arrow/vectorized/parquet/VectorizedDeltaEncodedValuesReader.java#L230-L266","documentation":"readBitWidthsForMiniBlocks reads the bit width byte for each mini block in a DELTA_BINARY_PACKED block header using BytesUtils.readIntLittleEndianOnOneByte. An IOException here (stream exhausted before all mini-block bit widths are read) is wrapped in ParquetDecodingException. It indicates the block header is truncated or the stream is misaligned.","triggerScenarios":"readBlockHeader -> readBitWidthsForMiniBlocks when the input stream ends (or errors) before miniBlocksPerBlock bit-width bytes have been consumed.","commonSituations":"Truncated or corrupt delta-encoded data pages, partial file uploads, or files written by a non-conforming encoder.","solutions":["Retry the read to exclude transient IO errors, then validate the file.","Rewrite the corrupt/truncated data files from source data.","Upgrade or fix the writer producing the delta-encoded files.","Fall back to non-vectorized reads while investigating."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  // vectorized read\n} catch (ParquetDecodingException e) {\n  if (e.getMessage().contains(\"Can not decode bitwidth in block header\")) {\n    // treat page/file as truncated: rewrite or fallback reader\n  } else throw e;\n}","preventionTips":["Verify file sizes/checksums after writes to catch truncation early","Avoid reading files mid-upload or from failed jobs","Test writer output with a Parquet validator before publishing"],"tags":["parquet","decoding","corrupt-data"],"backgroundTag":"file-read-failed","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"}