Skip to content

fix: Explicitly set boundary for multipart/form-data#1005

Merged
dbanty merged 7 commits into
openapi-generators:mainfrom
linkdd:multipart-boundary
May 30, 2026
Merged

fix: Explicitly set boundary for multipart/form-data#1005
dbanty merged 7 commits into
openapi-generators:mainfrom
linkdd:multipart-boundary

Conversation

@linkdd
Copy link
Copy Markdown
Contributor

@linkdd linkdd commented Mar 15, 2024

Python Version OpenAPI Client Generator Version
3.11.6 0.18.0

Actual Behavior

When an endpoint only has one body type, which is multipart/form-data, the Content-Type header is not set, so that HTTPX can set it with the correct boundary.

However, when an endpoint has multiple body types, the Content-Type header is always set, and HTTPX do not override it, which results in a missing boundary for multipart/form-data body types (resulting in a 400 - Bad Request response from the servers).

Proposed Changes

Let's always set the boundary to +++ to avoid any potential problem.

NB: This is kind of related to #1004, since in my specific case, the multipart/form-data body type is the last, it is always the one that is used.

@dbanty dbanty changed the title Explicitly set boundary for multipart/form-data fix: Explicitly set boundary for multipart/form-data May 30, 2026
@dbanty dbanty force-pushed the multipart-boundary branch from e48dfc7 to 9c3f8b1 Compare May 30, 2026 16:58
@dbanty dbanty force-pushed the multipart-boundary branch from 9c3f8b1 to cb36cbd Compare May 30, 2026 16:59
@dbanty dbanty added this pull request to the merge queue May 30, 2026
Merged via the queue into openapi-generators:main with commit fb3f866 May 30, 2026
41 of 43 checks passed
@knope-bot knope-bot Bot mentioned this pull request May 30, 2026
iloveitaly pushed a commit to iloveitaly/openapi-python-client that referenced this pull request May 31, 2026
> [!IMPORTANT]
> Merging this pull request will create this release

## Breaking Changes

- Drop support for Python 3.10
- Raise minimum httpx version to 0.23.1

## Features

- replace python-dateutil with stdlib datetime.fromisoformat (openapi-generators#1429)

## Fixes

- Remove some generated casts that aren't necessary with mypy v2 (openapi-generators#1436)
- Explicitly set boundary for multipart/form-data (openapi-generators#1005)

Co-authored-by: knope-bot[bot] <152252888+knope-bot[bot]@users.noreply.github.com>
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.

2 participants