python data_error ai_generated true

pydantic.errors.NumberError: 值不大于 100

pydantic.errors.NumberError: value is not less than or equal to 100

ID: python/pydantic-constraint-violation

其他格式: JSON · Markdown 中文 · English
80%修复率
86%置信度
0证据数
2024-02-28首次发现

版本兼容性

版本状态引入弃用备注
2.x active

根因分析

带有 Field(le=100) 的数字字段接收到大于 100 的值,违反了约束。

English

A numeric field with Field(le=100) receives a value greater than 100, violating the constraint.

generic

解决方案

  1. 90% 成功率
    Adjust input value to meet constraint: value = min(value, 100)
  2. 95% 成功率
    Modify Field constraint: Field(le=200)

无效尝试

常见但无效的做法:

  1. 50% 失败

    lt means strictly less than, so 100 would still fail.

  2. 70% 失败

    Type mismatch with constraints may cause issues.