infiniflow/ragflow · error · ValueError

{} not supported, should be non-negative numeric

Error message

 {} not supported, should be non-negative numeric

What it means

check_nonnegative_number raises when a param is not float/int/long or is negative. The permissive numeric validator: zero is allowed, only negative values and wrong types fail.

Source

Thrown at agent/component/base.py:281

    @staticmethod
    def check_nonnegative_integer(param, description):
        if type(param).__name__ not in ["int", "long"] or param < 0:
            raise ValueError(description + " {} not supported, should be 0 or positive integer".format(param))

    @staticmethod
    def check_positive_integer(param, description):
        if type(param).__name__ not in ["int", "long"] or param <= 0:
            raise ValueError(description + " {} not supported, should be positive integer".format(param))

    @staticmethod
    def check_positive_number(param, description):
        if type(param).__name__ not in ["float", "int", "long"] or param <= 0:
            raise ValueError(description + " {} not supported, should be positive numeric".format(param))

    @staticmethod
    def check_nonnegative_number(param, description):
        if type(param).__name__ not in ["float", "int", "long"] or param < 0:
            raise ValueError(description + " {} not supported, should be non-negative numeric".format(param))

    @staticmethod
    def check_decimal_float(param, description):
        if type(param).__name__ not in ["float", "int"] or param < 0 or param > 1:
            raise ValueError(description + " {} not supported, should be a float number in range [0, 1]".format(param))

    @staticmethod
    def check_boolean(param, description):
        if type(param).__name__ != "bool":
            raise ValueError(description + " {} not supported, should be bool type".format(param))

    @staticmethod
    def check_open_unit_interval(param, description):
        if type(param).__name__ not in ["float"] or param <= 0 or param >= 1:
            raise ValueError(description + " should be a numeric number between 0 and 1 exclusively")

    @staticmethod
    def check_valid_value(param, description, valid_values):

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Set the value to a number >= 0.
  2. Cast string numerics to float/int at the config boundary.
  3. If None appears, either supply a default >= 0 before check() or skip validation for genuinely optional fields.
  4. Add quick type assertions in DSL-generation scripts.

Example fix

# before
params = {"weight": "-0.5"}  # string AND negative

# after
params = {"weight": 0.5}
Defensive patterns

Strategy: type-guard

Validate before calling

def to_nonneg_number(v, field):
    if isinstance(v, bool) or not isinstance(v, (int, float)):
        raise ValueError(f'{field} must be numeric')
    if v < 0:
        raise ValueError(f'{field} must be >= 0')
    return v

Type guard

def is_nonneg_number(v) -> bool:
    return isinstance(v, (int, float)) and not isinstance(v, bool) and v >= 0

Try / catch

try:
    param.check()
except ValueError as e:
    if 'should be non-negative numeric' in str(e):
        conf[field] = abs(float(conf[field]))  # or fix at source
        param.update(conf); param.check()

Prevention

When it happens

Trigger: A component check() calling check_nonnegative_number(param, description) with a negative value or a non-numeric type (string, None, list).

Common situations: Temperature-like or weight params set negative by mistake; string numerics from JSON configs; None leaking from unset optional fields that are nonetheless validated.

Related errors


AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15). Data as JSON: /api/errors/8686c90e7fdf0eec. Report an issue: GitHub.