Skip to content

fix: preserve binary multipart chunks - #324

Open
Guflly wants to merge 1 commit into
openai:mainfrom
Guflly:fix/multipart-binary-chunks
Open

fix: preserve binary multipart chunks#324
Guflly wants to merge 1 commit into
openai:mainfrom
Guflly:fix/multipart-binary-chunks

Conversation

@Guflly

@Guflly Guflly commented Aug 3, 2026

Copy link
Copy Markdown

Summary

  • normalize multipart enumerator chunks to binary before buffering
  • keep bounded and whole-stream reads in binary encoding
  • add regression tests for mixed UTF-8 and binary chunks

Fixes #317.

Validation

  • focused adapter tests pass
  • RuboCop passes
  • the full util test file has one existing Windows CGI filename failure, reproduced on current main

@Guflly
Guflly requested a review from a team as a code owner August 3, 2026 01:59
@jbeckwith-oai jbeckwith-oai added the generator Touches generated SDK files label Aug 3, 2026

@jbeckwith-oai jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the adapter and all production call sites. Converting enumerated chunks to ASCII-8BIT before buffering preserves the exact bytes, eliminates UTF-8/BINARY compatibility failures, and leaves IO/StringIO behavior and transport framing unchanged. Bounded reads remain streaming with memory limited to the current source chunk/buffer; the unbounded-read path retains its existing whole-stream semantics. Regression coverage exercises both bounded and whole-stream mixed-encoding reads. Local validation: util suite 38/38 (160 assertions), focused mixed-encoding tests, an end-to-end multipart text+binary byte-integrity probe, RuboCop on both changed files, and git diff --check all pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

generator Touches generated SDK files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Encoding::CompatibilityError during multipart file upload is swallowed and reported as a generic APIConnectionError ("Connection error.")

2 participants