python
data_error
ai_generated
true
pydantic.errors.ListError: 列表长度至少为 3
pydantic.errors.ListError: list length must be at least 3
ID: python/pydantic-list-length-mismatch
80%修复率
84%置信度
0证据数
2024-01-15首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 2.x | active | — | — | — |
根因分析
带有 Field(min_length=3) 的列表字段接收到少于 3 个元素的列表。
English
A list field with Field(min_length=3) receives a list with fewer than 3 elements.
解决方案
-
90% 成功率
Ensure list has enough elements: data = data + [default]*n
-
95% 成功率
Adjust Field constraint: Field(min_length=1)
无效尝试
常见但无效的做法:
-
60% 失败
Validator must return value; otherwise ConfigError.
-
70% 失败
None may not be valid element type.