python
data_error
ai_generated
true
fastapi.exceptions.RequestValidationError: 422 - query parameter 'page' must be greater than or equal to 1
ID: python/fastapi-query-param-error
80%Fix Rate
85%Confidence
0Evidence
2024-02-25First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
查询参数不符合定义的约束条件,如最小值为 1。
generic中文
查询参数不符合定义的约束条件,如最小值为 1。
Workarounds
-
95% success
使用 Query(ge=1) 定义参数约束。
-
90% success
添加全局验证错误处理器返回清晰消息。
-
85% success
在客户端和服务器端都进行验证。
Dead Ends
Common approaches that don't work:
-
80% fail
忽略错误,不检查参数值。
-
60% fail
尝试在前端限制,但后端仍不验证。
-
70% fail
修改约束但忘记更新文档。