python
config_error
ai_generated
true
值错误:未知的路径转换器 'int'
ValueError: Unknown path converter 'int'
ID: python/starlette-route-param-converter
80%修复率
85%置信度
0证据数
2026-05-15首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
使用了 Starlette 不支持的路径转换器,如 int 但语法不正确。
English
Using a path converter that Starlette doesn't support, such as int without proper syntax.
解决方案
-
100% 成功率
Use the correct syntax: @app.route('/items/{item_id:int}') -
95% 成功率
In FastAPI, use type annotation: @app.get('/items/{item_id}') with item_id: int
无效尝试
常见但无效的做法:
-
70% 失败
Starlette uses {item_id:int} syntax, but it must be exactly that; if you use {item_id} with a type annotation, it's different.
-
30% 失败
The converter is built-in; no import needed.