{"record":{"id":"d50753ce53287a65","repo":"apache/iceberg","slug":"failed-to-read-bytes-from-stream","errorCode":null,"errorMessage":"Failed to read bytes from stream","messagePattern":"Failed to read bytes from stream","errorType":"exception","errorClass":"UncheckedIOException","httpStatus":null,"severity":"error","filePath":"arrow/src/main/java/org/apache/iceberg/arrow/vectorized/parquet/VectorizedByteStreamSplitValuesReader.java","lineNumber":140,"sourceCode":"  }\n\n  private void ensureDecoded() {\n    if (decodedDataStream == null) {\n      Preconditions.checkState(\n          totalBytesInStream % elementSizeInBytes == 0,\n          \"Stream size %s is not a multiple of element size %s\",\n          totalBytesInStream,\n          elementSizeInBytes);\n      this.decodedDataStream = decode(totalBytesInStream / elementSizeInBytes);\n    }\n  }\n\n  private ByteBuffer decode(int valuesCount) {\n    ByteBuffer encoded;\n    try {\n      encoded = dataStream.slice(totalBytesInStream).slice();\n    } catch (EOFException e) {\n      throw new UncheckedIOException(\"Failed to read bytes from stream\", e);\n    }\n    byte[] decoded = new byte[encoded.limit()];\n    int destByteIndex = 0;\n    for (int srcValueIndex = 0; srcValueIndex < valuesCount; srcValueIndex++) {\n      for (int stream = 0; stream < elementSizeInBytes; stream++, destByteIndex++) {\n        decoded[destByteIndex] = encoded.get(srcValueIndex + stream * valuesCount);\n      }\n    }\n    return ByteBuffer.wrap(decoded).order(ByteOrder.LITTLE_ENDIAN);\n  }\n}\n","sourceCodeStart":122,"sourceCodeEnd":152,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/arrow/src/main/java/org/apache/iceberg/arrow/vectorized/parquet/VectorizedByteStreamSplitValuesReader.java#L122-L152","documentation":"decode() slices totalBytesInStream bytes from the data stream; an EOFException means the stream ended before all encoded byte streams were available, wrapped in UncheckedIOException with this message.","triggerScenarios":"BYTE_STREAM_SPLIT page truncated relative to totalBytesInStream (valuesCount * elementSizeInBytes streams missing bytes) during ensureDecoded.","commonSituations":"Truncated Parquet files from aborted writes, S3 reads interrupted mid-object, wrong page-size metadata.","solutions":["Regenerate or re-fetch the Parquet file — the page is truncated/corrupt.","Retry if the cause was a transient network/object-store read failure.","Validate files after write (checksum) to catch truncation early."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// catch (UncheckedIOException e) {\n//   if (e.getCause() instanceof EOFException) { refetchOrRegenerateFile(); }\n//   else throw e;\n// }","preventionTips":["Verify file completeness (checksum/size) before scanning.","Retry object-store reads on transient failures.","Ensure writers flush and commit atomically so readers never see partial files."],"tags":["parquet","byte-stream-split","io","truncated-file"],"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-14T11:17:12.474Z"}