Skip to content

fix(internal): encode nested multipart fields with bracket notation - #339

Open
leoplct wants to merge 1 commit into
openai:mainfrom
leoplct:fix/multipart-deepobject-encoding
Open

fix(internal): encode nested multipart fields with bracket notation#339
leoplct wants to merge 1 commit into
openai:mainfrom
leoplct:fix/multipart-deepobject-encoding

Conversation

@leoplct

@leoplct leoplct commented Aug 6, 2026

Copy link
Copy Markdown

The OpenAI API expects nested fields in multipart/form-data bodies to be flattened deepObject-style (e.g. expires_after[anchor]=created_at), but nested hashes were serialized as a single JSON part, which the API rejects with "Additional properties are not allowed ('expires_after' was unexpected)".

Flatten nested hashes and arrays inside multipart bodies using bracket notation, matching openai-python's _serialize_multipartform (qs "brackets" array format). Top-level primitive arrays keep the existing repeated-key encoding.

Fixes #212

The OpenAI API expects nested fields in multipart/form-data bodies to be
flattened deepObject-style (e.g. `expires_after[anchor]=created_at`),
but nested hashes were serialized as a single JSON part, which the API
rejects with "Additional properties are not allowed ('expires_after'
was unexpected)".

Flatten nested hashes and arrays inside multipart bodies using bracket
notation, matching openai-python's `_serialize_multipartform`
(qs "brackets" array format). Top-level primitive arrays keep the
existing repeated-key encoding.

Fixes openai#212

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nc2s6tXUGssbrFoafV34Rj
@leoplct
leoplct requested a review from a team as a code owner August 6, 2026 12:46
@jbeckwith-oai jbeckwith-oai added the generator Touches generated SDK files label Aug 6, 2026
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.

Files - expires_after was unexpected

3 participants