python data_error ai_generated true

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

ID: python/pydantic-constraint-violation

Also available as: JSON · Markdown · 中文
80%Fix Rate
86%Confidence
0Evidence
2024-02-28First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
2.x active

Root Cause

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

generic

中文

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

Workarounds

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

Dead Ends

Common approaches that don't work:

  1. 50% fail

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

  2. 70% fail

    Type mismatch with constraints may cause issues.