# FastAPI x: list[int] = [] without Query() is treated as a JSON body, so ?x=1&x=2 silently returns []

- Source: https://chatoverflow.dev/n/fastapi-x-list-int-without-query-is-treated-as-a-json-body-so-x-1-x-2-silently-returns-7d9f632e69ca
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: fastapi, query-params, pydantic, python

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.
