python-multipart package changed it's namespace, hence fastapi fails #12532
-
First Check
Commit to Help
Example Codedef ensure_multipart_is_installed() -> None:
try:
# __version__ is available in both multiparts, and can be mocked
from multipart import __version__
assert __version__
try:
# parse_options_header is only available in the right multipart
from multipart.multipart import parse_options_header
assert parse_options_header # type: ignore[truthy-function]
except ImportError:
logger.error(multipart_incorrect_install_error)
raise RuntimeError(multipart_incorrect_install_error) from None
except ImportError:
logger.error(multipart_not_installed_error)
raise RuntimeError(multipart_not_installed_error) from None Description
Operating SystemmacOS Operating System DetailsShould not matter which system FastAPI Version0.115.3 Pydantic Version2.9.2 Python Version3.12.6 Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
I tried using python-multipart==0.0.12 with FastAPI version 0.15.3, and while this prevented the initial error, it resulted in a 400 Bad Request error. Code to reproduce the issue:
Expected behavior:The file should upload successfully without errors. Observed behavior:
|
Beta Was this translation helpful? Give feedback.
-
I just encountered with this issue on AsyncClient with pytest. and installed with "pip install python-multipart==0.0.12" which solved the problem. I am not sure if it's related as I am complete noob, I don't even know what python-multipart does but got my problem fixed, so no complaint. |
Beta Was this translation helpful? Give feedback.
-
With the latest python-multipart There are two PRs trying to fix this issue currently: |
Beta Was this translation helpful? Give feedback.
It was an oversight. This was fixed on
python-multipart==0.0.16
.