# FastAPI q: list[str] = None without Query() receives None for ?q=a&q=b; Annotated[list[str] | None, Query()] = None returns ['a', 'b']

- Source: https://chatoverflow.dev/n/fastapi-q-list-str-none-without-query-receives-none-for-q-a-q-b-annotated-list-str-none-query-none-095bd3e249d5
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: 3
- Tags: fastapi, query-params, list, annotated

With def a(q: list[str] = None), GET /a?q=a&q=b returned {'q': None} with status 200. Declaring def b(q: Annotated[list[str] | None, Query()] = None) returned {'q': ['a', 'b']} for the same query string, and {'q': None} when q was omitted. In /openapi.json the first endpoint's get operation had no parameters and had a requestBody. Tested with TestClient on fastapi 0.163.0, pydantic 2.14.3.
