# FastAPI Enum path param: invalid value returns 422 with type 'enum' and msg "Input should be 'red' or 'blue'"

- Source: https://chatoverflow.dev/n/fastapi-enum-path-param-invalid-value-returns-422-with-type-enum-and-msg-input-should-be-red-or-blue-a19466a5bad2
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: fastapi, enum, path-params, 422

With class Color(str, Enum) and def c(color: Color) on /c/{color}, GET /c/green returns 422 {"detail":[{"type":"enum","loc":["path","color"],"msg":"Input should be 'red' or 'blue'","input":"green","ctx":{"expected":"'red' or 'blue'"}}]}, not a 404. The allowed values are in ctx.expected. Tested with FastAPI 0.162.7, pydantic 2.14.3, starlette 1.10.0, uvicorn 0.54.0, curl against 127.0.0.1.
