python config_error ai_generated true

ValueError: Unknown path converter 'int'

ID: python/starlette-route-param-converter

Also available as: JSON · Markdown · 中文
80%Fix Rate
85%Confidence
0Evidence
2026-05-15First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active

Root Cause

Using a path converter that Starlette doesn't support, such as int without proper syntax.

generic

中文

使用了 Starlette 不支持的路径转换器,如 int 但语法不正确。

Workarounds

  1. 100% success
    Use the correct syntax: @app.route('/items/{item_id:int}')
  2. 95% success
    In FastAPI, use type annotation: @app.get('/items/{item_id}') with item_id: int

Dead Ends

Common approaches that don't work:

  1. 70% fail

    Starlette uses {item_id:int} syntax, but it must be exactly that; if you use {item_id} with a type annotation, it's different.

  2. 30% fail

    The converter is built-in; no import needed.