Skip to content

fix(generation): let httpx choose the multipart boundary - #542

Merged
jwulf merged 3 commits into
mainfrom
fix/multipart-boundary
Dec 1, 2026
Merged

jwulf merged 3 commits into
mainfrom
fix/multipart-boundary

Conversation

@jwulf

@jwulf jwulf commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Closes #541

Problem

openapi-python-client 0.29 makes every multipart endpoint send Content-Type: multipart/form-data; boundary=+++. httpx encodes the body with that boundary, so an uploaded file containing \r\n--+++ ended its part early. Affected endpoints:

  • create_deployment (and so deploy_resources_from_files)
  • create_document
  • create_documents

Fix

Post-gen hook 0420_drop_fixed_multipart_boundary.py removes that header line, so httpx sets Content-Type with a random boundary for each request. This is what upstream does in 0.30 (openapi-generators/openapi-python-client#1511). We can't take 0.30 yet because it moves generated clients to httpx2 (#390). Once the generator stops emitting the line, the hook does nothing.

Commits

  1. Red: test_multipart_boundary.py fails on the current output. The scan finds 3 pinned boundaries, and all 3 endpoints truncate a payload containing \r\n--+++ to <definitions>.
  2. Fix: the hook, plus unit tests for it covering quote and whitespace variants and headers it must leave alone.
  3. Regenerated output: 3 lines removed, nothing else.

The test covers the whole class of defect:

  • It scans every generated endpoint for a pinned boundary.
  • It round-trips the payload through every multipart endpoint the scan finds.
  • It fails if a new multipart endpoint has no round-trip body yet.

Checks

make generate, make lint, make typecheck and make test all pass (1941 passed). No local Camunda was available for an integration run.

Labelled backport stable/10 and backport stable/9: both lines have the same bug.

jwulf added 3 commits December 1, 2026 16:14
openapi-python-client 0.29 makes every multipart endpoint send
Content-Type: multipart/form-data; boundary=+++. httpx encodes the body
with that boundary, so an uploaded file containing "\r\n--+++" ended its
part early and the rest was parsed as a malformed extra part. This hit
create_deployment (and deploy_resources_from_files), create_document and
create_documents.

Post-gen hook 0420 removes that header line, so httpx sets Content-Type
with a random boundary for each request. Upstream made the same change
in 0.30 (openapi-generators/openapi-python-client#1511). We can't take
0.30 yet because it moves generated clients to httpx2.

Closes #541
@jwulf
jwulf requested a review from a team as a code owner December 1, 2026 15:17
@jwulf jwulf added the backport stable/10 Backport to stable/10 after merge label Dec 1, 2026
Copilot AI balanced review requested due to automatic review settings December 1, 2026 15:17
@jwulf

jwulf commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

🤖 The changes in this PR were produced by nano-agent, an autonomous agent. Commits are authored under the operator's own git identity when one is resolvable (the human running the fleet), so they can satisfy CLA/DCO requirements; this note records that the work was generated by the agent.

Copilot AI 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.

🟢 Approval recommended

No active review issues remain for the multipart upload boundary fix.

No open issues 🎉

What changed in this PR

Fixes multipart upload corruption by letting httpx choose a random boundary instead of using the generator’s fixed +++ boundary. This addresses #541 without requiring the generator upgrade that switches to httpx2.

Changes:

  • Adds a post-generation hook to remove fixed multipart boundary headers.
  • Regenerates all three affected upload endpoints.
  • Adds endpoint-wide boundary checks, payload round-trip tests, and focused hook tests.
File Description
tests/​acceptance/​test_multipart_boundary.py Adds regression coverage for multipart boundaries and hook behavior.
hooks/​post_gen/​0420_drop_fixed_multipart_boundary.py Removes generated headers that pin multipart boundaries.
generated/​camunda_orchestration_sdk/​api/​resource/​create_deployment.py Lets httpx choose the deployment upload boundary.
generated/​camunda_orchestration_sdk/​api/​document/​create_documents.py Lets httpx choose the multiple-document upload boundary.
generated/​camunda_orchestration_sdk/​api/​document/​create_document.py Lets httpx choose the single-document upload boundary.

Review effort: Balanced

@jwulf

jwulf commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

nano-ack: issuecomment-7315691027 — attribution note acknowledged; it is informational and needs no code change.

@jwulf jwulf added the backport stable/9 Backport to stable/9 after merge label Dec 1, 2026
@jwulf
jwulf merged commit 0bea8e3 into main Dec 1, 2026
38 checks passed
@camunda-sdk-automation

Copy link
Copy Markdown
Contributor

Successfully created backport PR for stable/10:

@camunda-sdk-automation

Copy link
Copy Markdown
Contributor

Successfully created backport PR for stable/9:

jwulf added a commit that referenced this pull request Dec 1, 2026
* test(generation): reproduce truncated multipart uploads from the fixed boundary

Refs #541

* fix(generation): let httpx choose the multipart boundary

openapi-python-client 0.29 makes every multipart endpoint send
Content-Type: multipart/form-data; boundary=+++. httpx encodes the body
with that boundary, so an uploaded file containing "\r\n--+++" ended its
part early and the rest was parsed as a malformed extra part. This hit
create_deployment (and deploy_resources_from_files), create_document and
create_documents.

Post-gen hook 0420 removes that header line, so httpx sets Content-Type
with a random boundary for each request. Upstream made the same change
in 0.30 (openapi-generators/openapi-python-client#1511). We can't take
0.30 yet because it moves generated clients to httpx2.

Closes #541

* chore(generation): regenerate SDK for the multipart boundary fix

(cherry picked from commit 0bea8e3)

Co-authored-by: Josh Wulf <josh.wulf@camunda.com>
jwulf added a commit that referenced this pull request Dec 1, 2026
… to stable/9) (#544)

* fix(generation): let httpx choose the multipart boundary (#542)

* test(generation): reproduce truncated multipart uploads from the fixed boundary

Refs #541

* fix(generation): let httpx choose the multipart boundary

openapi-python-client 0.29 makes every multipart endpoint send
Content-Type: multipart/form-data; boundary=+++. httpx encodes the body
with that boundary, so an uploaded file containing "\r\n--+++" ended its
part early and the rest was parsed as a malformed extra part. This hit
create_deployment (and deploy_resources_from_files), create_document and
create_documents.

Post-gen hook 0420 removes that header line, so httpx sets Content-Type
with a random boundary for each request. Upstream made the same change
in 0.30 (openapi-generators/openapi-python-client#1511). We can't take
0.30 yet because it moves generated clients to httpx2.

Closes #541

* chore(generation): regenerate SDK for the multipart boundary fix

(cherry picked from commit 0bea8e3)

* test: scan the imported SDK for multipart endpoints, not generated/

Signed-off-by: Josh Wulf <josh.wulf@camunda.com>

---------

Signed-off-by: Josh Wulf <josh.wulf@camunda.com>
Co-authored-by: Josh Wulf <josh.wulf@camunda.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport stable/9 Backport to stable/9 after merge backport stable/10 Backport to stable/10 after merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multipart uploads use a fixed boundary, corrupting files that contain it

2 participants