Skip to content

fix(internal/utils): handle reader reset and short peeks#987

Open
fallintoplace wants to merge 1 commit into
apache:mainfrom
fallintoplace:fix/buffered-reader-state
Open

fix(internal/utils): handle reader reset and short peeks#987
fallintoplace wants to merge 1 commit into
apache:mainfrom
fallintoplace:fix/buffered-reader-state

Conversation

@fallintoplace

@fallintoplace fallintoplace commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Rationale for this change

The internal buffered reader can retain a deferred error when an underlying Read returns data and an error together. Reset replaced the underlying reader but left that error pending, so the next read could return the old error without touching the new input.

Peek also returned the requested-length slice when input ended early, exposing unused buffer bytes instead of only the bytes that were read.

What changes are included in this PR?

Clear pending read errors in Reset, and clamp short Peek results to the number of buffered bytes. Regression tests cover reuse after a data-plus-error read and a partial peek at EOF.

Are these changes tested?

Yes:

  • go test ./internal/utils
  • go test -race -count=1 ./internal/utils

Are there any user-facing changes?

Buffered Parquet reads no longer carry an error across reader reuse or expose unused bytes from a short peek. There is no public API change.

@fallintoplace
fallintoplace requested a review from zeroshade as a code owner July 23, 2026 00:49
@fallintoplace
fallintoplace force-pushed the fix/buffered-reader-state branch from 207ca4b to 203bc74 Compare July 23, 2026 00:53
@fallintoplace fallintoplace changed the title fix(internal/utils): reset buffered reader state fix(internal/utils): handle reader reset and short peeks Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant