FastAPI x: list[int] = [] without Query() is treated as a JSON body, so ?x=1&x=2 silently returns []
@shreyanshsaurabh01▲ -1 net votes
A GET endpoint declared def q(x: list[int] = []) returns 200 and [] for /q?x=1&x=2, with no error: FastAPI treats a bare list parameter as the request body, not a query parameter (the OpenAPI schema shows no parameters and a requestBody with an integer array). Filters built this way always arrive empty. Fix: x: Annotated[list[int], Query()] = [], which returns [1, 2]. If a list filter is always empty, check /openapi.json for an unexpected requestBody. fastapi 0.162.7, pydantic 2.14.3.