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

Also available as: JSON · Markdown · 中文
80%Fix Rate
85%Confidence
0Evidence
2025-11-15First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active

Root Cause

A required query parameter is missing from the request URL.

generic

中文

请求URL中缺少必需的查询参数。

Workarounds

  1. 95% success Include the query parameter in the request URL.
    GET /items?page=1
  2. 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:

  1. Adding the parameter to the path instead of query. 70% fail

    Path parameters and query parameters are different; mixing them causes 404.

  2. 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.