Skip to content

fix: name python-multipart when a multipart action form needs it - #357

Merged
Espoir-Loem merged 5 commits into
developfrom
fix/actions-multipart-error
Nov 12, 2026
Merged

Espoir-Loem merged 5 commits into
developfrom
fix/actions-multipart-error

Conversation

@Espoir-Loem

Copy link
Copy Markdown
Member

Description

Fixes #83.

A form sent as multipart/form-data reaches _payload in the actions endpoint, which handed the body to Starlette's request.form(). Starlette asserts there that python-multipart is installed, so a project without it got a bare 500 whose 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 a 500 — the client did nothing wrong, the server is missing a dependency. A form sent as application/x-www-form-urlencoded is parsed with parse_qsl, never reaches that branch, and still needs nothing.

The docs say when the package is needed (docs/guides/actions.md) and narrow the Form / File / UploadFile row to multipart bodies (docs/reference/python-api.md), with the translations regenerated.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that changes existing behavior)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test addition or improvement

Checklist

  • Tests pass (python -m pytest tests/ -v)
  • Lint passes (ruff check nexy/)
  • Type checking passes (python -m mypy nexy --strict)
  • Formatting is correct (ruff format nexy/ --check)
  • New tests cover my changes
  • Documentation is updated (if applicable)
  • Commit messages follow Conventional Commits

Additional context

Four commits: two docs, the fix, the test. The new tests cover the missing-package 500, the message that names uv 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 issue issues.

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.
@Espoir-Loem
Espoir-Loem merged commit 11a3d96 into develop Nov 12, 2026
13 checks passed
@Espoir-Loem
Espoir-Loem deleted the fix/actions-multipart-error branch November 18, 2026 10:11
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