Skip to content

Fix byte-limited reads for Enumerator-backed request bodies#275

Open
fallintoplace wants to merge 1 commit into
openai:mainfrom
fallintoplace:fix/read-io-adapter-byte-read
Open

Fix byte-limited reads for Enumerator-backed request bodies#275
fallintoplace wants to merge 1 commit into
openai:mainfrom
fallintoplace:fix/read-io-adapter-byte-read

Conversation

@fallintoplace
Copy link
Copy Markdown

Summary

  • fix Enumerator-backed ReadIOAdapter#read(max_len) to return at most max_len bytes
  • use byte-oriented buffer slicing for streamed request bodies
  • preserve already buffered bytes when read(nil) follows a partial read
  • clear out_string consistently at EOF
  • add regression tests for zero-length reads, byte lengths, EOF, output buffers, and buffered reads

Fixes #274.

Test plan

  • bundle exec rake TEST=test/openai/internal/util_test.rb test
  • bundle exec rake lint

@fallintoplace fallintoplace marked this pull request as ready for review May 19, 2026 17:41
@fallintoplace fallintoplace requested a review from a team as a code owner May 19, 2026 17:41
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.

ReadIOAdapter#read returns too many bytes for Enumerator bodies

1 participant