fix: encode multipart array and nested fields - #348
Merged
Conversation
Contributor
Encode arrays and nested objects recursively with bracket notation while preserving scalar multipart fields. Escape all Content-Disposition parameters and cover generated request models for transcription, image editing, and file expiration.
jbeckwith-oai
force-pushed
the
codex/fix-multipart-form-encoding
branch
from
August 9, 2026 20:51
8ba6ba2 to
9d04855
Compare
This was referenced Aug 10, 2026
apcha-oai
approved these changes
Aug 10, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
field[], including both primitive and file arraysnameandfilenameContent-DispositionparametersRoot cause
The shared multipart writer repeated top-level primitive and file arrays using the scalar field name and serialized nested hashes as JSON parts. The API's form parser expects the same global brackets format used by openai-python and by the transformed OpenAPI examples.
Before:
timestamp_granularities=wordandtimestamp_granularities=segmentimagefile partsexpires_afterpartAfter:
timestamp_granularities[]=wordandtimestamp_granularities[]=segmentimage[]file parts, while a single image remainsimageexpires_after[anchor]=created_atandexpires_after[seconds]=3600The implementation replaces the old top-level array special case with one recursive field writer. It preserves insertion order, array order, duplicate values, and streaming file contents without materializing a flattened body.
This consolidates and supersedes #249, #311, and #339.
Fixes #201.
Fixes #212.
Fixes #253.
Validation
mise exec ruby@4.0.6 -- bundle exec ruby -Itest test/openai/internal/util_test.rb— 45 runs, 178 assertionsmise exec ruby@4.0.6 -- ./scripts/test— 522 runs, 1,709 assertionsmise exec ruby@4.0.6 -- bundle exec rake lint— 2,596 files, no RuboCop offenses; Sorbet clean; 1,211 RBS files validmise exec ruby@4.0.6 -- bundle exec rake build:gem— builtopenai-0.78.0.gemgit diff --check