python
network_error
ai_generated
true
starlette.formparsers.MultiPartException: multipart 中缺少 boundary。
starlette.formparsers.MultiPartException: Missing boundary in multipart.
ID: python/starlette-missing-boundary-multipart
80%修复率
85%置信度
0证据数
2024-06-18首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
multipart/form-data 请求的 Content-Type 头缺少 boundary 参数,或客户端发送了请求体却没有该头。
English
A multipart/form-data request lacks the boundary parameter in its Content-Type header, or the client sends a body without the header.
解决方案
-
95% 成功率
import requests files = {'file': open('a.png', 'rb')} requests.post(url, files=files) -
92% 成功率
from fastapi import File, UploadFile @app.post('/upload') async def upload(file: UploadFile = File(...)): ...
无效尝试
常见但无效的做法:
-
80% 失败
The endpoint expects form fields and fails validation.
-
70% 失败
Does not fix the client; uploads keep failing.