python
type_error
ai_generated
true
值错误:99 不是有效的 HTTP 状态码
ValueError: 99 is not a valid HTTP status code
ID: python/starlette-http-exception-invalid-status
80%修复率
85%置信度
0证据数
2025-11-05首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
向 HTTPException 或 Response 传递了无效的状态码。
English
Passing an invalid status code to HTTPException or Response.
解决方案
-
100% 成功率
Use a valid status code: raise HTTPException(status_code=404, detail='Not Found')
-
90% 成功率
Check the status code before using: if 100 <= code <= 599: use it else: raise ValueError
无效尝试
常见但无效的做法:
-
90% 失败
Status codes must be integers between 100 and 599.
-
80% 失败
600 is not a standard HTTP status code.