Skip to content

Feature: accept multipart bodies in json routes - #173

Merged
krishan711 merged 1 commit into
mainfrom
multipart-requests
Oct 22, 2026
Merged

krishan711 merged 1 commit into
mainfrom
multipart-requests

Conversation

@krishan711

Copy link
Copy Markdown
Contributor

Description

json_route and streaming_json_route (so also route) now accept multipart/form-data bodies, so API routes can receive file uploads.

  • Body parsing moves to core.api.request_body.read_request_body, which both routes use. JSON bodies work as before.
  • Multipart form fields are used like JSON body fields, so pydantic still validates and coerces them (e.g. "41" to 41). Uploaded files are passed as the new core.api.uploaded_file.UploadedFile (filename, contentType, content), so request models declare file: UploadedFile.
  • A form field given more than once raises BadRequestException (400).
  • The core-api extra now installs python-multipart, which starlette's form parsing needs.

The local full test run has 37 failures in tests/caching and tests/util/test_file_util.py. The same 37 fail on main locally. tests/api passes, including the 2 new multipart tests.

Checklist:

  • I have updated the CHANGELOG with a summary of my changes

@krishan711
krishan711 merged commit 7f4c941 into main Oct 22, 2026
4 checks passed
@krishan711
krishan711 deleted the multipart-requests branch October 22, 2026 08:52
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.

1 participant