python
data_error
ai_generated
true
pydantic.error_wrappers.ValidationError: Model 的 1 个验证错误 不允许额外字段
pydantic.error_wrappers.ValidationError: 1 validation error for Model extra field not permitted
ID: python/pydantic-extra-fields-forbidden
80%修复率
89%置信度
0证据数
2024-03-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 2.x | active | — | — | — |
根因分析
模型配置为 extra='forbid',但接收到了模型中未定义的额外字段。
English
Model is configured with extra='forbid' but receives additional fields not defined in the model.
解决方案
-
90% 成功率
Set extra='ignore' to silently drop extra fields
-
85% 成功率
Add the extra field to model if needed
无效尝试
常见但无效的做法:
-
50% 失败
This may not be desired; better to allow or ignore.
-
70% 失败
Data may be lost or inconsistent.