Repository navigation
fix: name python-multipart when a multipart action form needs it - #357
Merged
Merged
Conversation
A form sent as `application/x-www-form-urlencoded`, which is what a browser sends by default, needs no extra package. Add `enctype="multipart/form-data"` and the call needs `python-multipart`; without it the action answers 500 with a message naming `uv add python-multipart` (#83). An action also reads fields, not files: a file input reaches it as a string, so an upload belongs to a route in `src/routes/api/`.
The `Form`, `File`, `UploadFile` row said all three need the package. A form sent as `application/x-www-form-urlencoded` is parsed with `parse_qsl` and needs nothing; only `enctype="multipart/form-data"` does (#83).
`_payload` handed a `multipart/form-data` body to Starlette's `request.form()`, which asserts that `python-multipart` is installed: a project without it got a bare 500 whose traceback buried the package name (#83). The call now checks for the parser first and raises an error that names the package and the command this project uses, `uv add python-multipart`. It stays a 500: the client did nothing wrong, the server is missing a package. A urlencoded form never reaches that branch and still needs nothing.
The call is a 500 rather than a 400, the error names `uv add python-multipart`, and a urlencoded form still runs with the package missing.
This was referenced Nov 14, 2026
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.
Description
Fixes #83.
A form sent as
multipart/form-datareaches_payloadin the actions endpoint, which handed the body to Starlette'srequest.form(). Starlette asserts there thatpython-multipartis installed, so a project without it got a bare500whose traceback buried the package name.The call now checks for the parser first and raises a message that names the package and the command this project uses:
uv add python-multipart. It stays a500— the client did nothing wrong, the server is missing a dependency. A form sent asapplication/x-www-form-urlencodedis parsed withparse_qsl, never reaches that branch, and still needs nothing.The docs say when the package is needed (
docs/guides/actions.md) and narrow theForm/File/UploadFilerow to multipart bodies (docs/reference/python-api.md), with the translations regenerated.Type of change
Checklist
python -m pytest tests/ -v)ruff check nexy/)python -m mypy nexy --strict)ruff format nexy/ --check)Additional context
Four commits: two docs, the fix, the test. The new tests cover the missing-package
500, the message that namesuv add python-multipart, and a urlencoded form that still runs without the package.Two contributors offered to take #83 while it was already being fixed on this branch; I will thank them and point them at the open
good first issueissues.