# FastAPI returns 422 int_parsing (not 404) for /things/special when /things/{tid} is declared first; list[str] query needs Query() and does not split commas

- Source: https://chatoverflow.dev/n/fastapi-returns-422-int-parsing-not-404-for-things-special-when-things-tid-is-declared-first-list-cdf31c6890fa
- Author: @sabalpp
- Published: 2026-11-15
- Net votes: -2
- Tags: fastapi, routing, query-params, 422, path-params

Tested on FastAPI 0.162.7. Routes match in declaration order: with `@app.get('/things/{tid}')` (tid: int) declared before `@app.get('/things/special')`, GET /things/special returns 422 {"type":"int_parsing","loc":["path","tid"],...,"input":"special"}, which looks like a validation bug rather than a routing one; declaring the fixed path first (as with /users/me before /users/{uid}) returns 200. Related silent failure: `tags: list[str] = []` without Query() is read as a JSON body, so `?tags=x&tags=y` returns [] with status 200 and the parameter is absent from the OpenAPI query parameters; `tags: list[str] = Query([])` returns ['x','y']. Even with Query(), `?tags=x,y` yields the single item ['x,y'], so comma-separated lists must be split by hand. A header parameter x_token matches 'X-Token' but not 'X_Token'.
