JustinBinber opened a new pull request, #41670:
URL: https://github.com/apache/beam/pull/41670

   Fixes #41669.
   
   Concatenated bzip2, lzma and zstd files can fail if a member ends exactly at 
an input-read boundary. The decoder has reached EOF with empty `unused_data`, 
and the next raw chunk is incorrectly passed to that finished decoder. A 
positive bounded read or `readline()` reproduces this without relying on 
unlimited read sizes.
   
   Restart the decompressor when it is at EOF and another nonempty chunk is 
ready. This handles both buffered `unused_data` and the next raw read, while 
preserving the decoder for continuation of the current member and avoiding 
resets at physical EOF.
   
   The regression uses real files across all five codecs, with nonempty, 
leading/interior/trailing empty and all-empty members. It exercises bounded 
reads, line reads, EOF, logical positions and rewind. On the unchanged base, 
bzip2/lzma/zstd fail 24 subcases; gzip/deflate pass the 16 control subcases. 
All pass with the fix.
   
   Validation on Windows / Python 3.11.7:
   
   - Full `filesystem_test.py` and `localfilesystem_test.py`, plus 
`fileio_test.py::ReadTest`, `WriteFilesTest` and 
`textio_test.py::TextSinkTest`: 127 tests and 50 subtests passed, one existing 
skip on FnApiRunner. The separate TestStream test passed on 
BundleBasedDirectRunner (128 tests passed in total).
   - A real 16 MiB zstd first frame through `FileSystems.open` and 
`ReadableFile.read`: both raise on the base and return the exact 
16,776,835-byte payload with the fix, matching an independent zstd stream 
reader.
   - Ruff 0.17.6, YAPF 0.43.0, Pyrefly 1.5.0 (0 errors) and whitespace checks 
pass.
   
   This branch starts from current master and is independent of #41622. Related 
#22939 reports a separate old zstandard debug assertion; this PR does not claim 
that debug-build coverage. Source tests reused released 2.78.0 generated 
protobuf bindings; a fresh SDK build, cloud execution and the full 
runner/OS/Python matrix were not run.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to