python
type_error
ai_generated
true
fastapi.exceptions.RequestValidationError: field required (type=value_error.missing) for query parameter 'page'
ID: python/fastapi-missing-query-parameter
80%Fix Rate
85%Confidence
0Evidence
2025-11-15First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
A required query parameter is missing from the request URL.
generic中文
请求URL中缺少必需的查询参数。
Workarounds
-
95% success Include the query parameter in the request URL.
GET /items?page=1
-
90% success Make the query parameter optional with a default value.
async def read_items(page: int = 1):
Dead Ends
Common approaches that don't work:
-
Adding the parameter to the path instead of query.
70% fail
Path parameters and query parameters are different; mixing them causes 404.
-
Setting a default value but not making it optional in the function signature.
60% fail
If the parameter is required in the function, a default may not be used.