damccorm opened a new pull request, #41163: URL: https://github.com/apache/beam/pull/41163
### Summary Fixes a splittable CSV/text read race in `_TruncatingFileHandle` (`sdks/python/apache_beam/dataframe/io.py`) exposed by `CsvTest.test_non_utf8_csv_read_write` in `PreCommit Python (3.14)` ([run 42817903097](https://github.com/apache/beam/actions/runs/42817903097)). ### Root Cause When a restriction `[start, stop)` with `start > len(header)` is initialized in `_TruncatingFileHandle.__init__`, it skips past the first record delimiter at or after `start` and sets `self._buffer_start_pos` to the start of the following record. If `stop` equals that exact record boundary (`offset = stop - self._buffer_start_pos == 0` with `stop > len(header)`), `_TruncatingFileHandle._read` previously treated `offset <= 0` as empty (`res = self._empty`), while the subsequent restriction `[stop, ...)` starts scanning at `stop` and also skips the record starting at `stop`, dropping that record completely. ### Fix Only return `self._empty` when `offset < 0` or `stop <= self._header_len`, so a post-header restriction whose `self._buffer_start_pos == stop` reads the record starting at `stop` that the following restriction `[stop, ...)` skips. ### Verification - Triggered `beam_PreCommit_Python.yml` workflow run on branch: [`42832034988`](https://github.com/apache/beam/actions/runs/42832034988) -- 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]
