infiniflow/ragflow · error · ValueError

should be a numeric number between 0 and 1 exclusively

Error message

 should be a numeric number between 0 and 1 exclusively

What it means

Raised by ComponentParamBase.check_open_unit_interval in agent/component/base.py when a parameter must be strictly inside (0, 1): the value's exact type name must be 'float' (ints are rejected here, unlike check_decimal_float) and it must satisfy 0 < param < 1. This targets values like sampling 'presence penalty'-style ratios where 0 and 1 are both invalid. Minor caveat: unlike sibling validators, this message does not interpolate the offending value, so only the description prefix identifies the parameter.

Source

Thrown at agent/component/base.py:296

    @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):
        if param not in valid_values:
            raise ValueError(description + " {} is not supported, it should be in {}".format(param, valid_values))

    @staticmethod
    def check_defined_type(param, description, types):
        if type(param).__name__ not in types:
            raise ValueError(description + " {} not supported, should be one of {}".format(param, types))

    @staticmethod
    def check_and_change_lower(param, valid_list, description=""):
        if type(param).__name__ != "str":
            raise ValueError(description + " {} not supported, should be one of {}".format(param, valid_list))

        lower_param = param.lower()
        if lower_param in valid_list:

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Set the parameter to a strict float strictly between 0 and 1, e.g. 0.9 (not 1, not 0, not an int)
  2. If the semantic you want is 'disabled', check whether the component supports leaving the field empty or 0 via a different parameter instead of 0 here
  3. Coerce string inputs to float(value) before assignment if config comes from a text source

Example fix

# before
"diversity": 1

# after
"diversity": 0.9
Defensive patterns

Strategy: validation

Validate before calling

def as_open_unit_interval(v, name):
    if not isinstance(v, float):
        v = float(v)  # ints are rejected by the validator; force float
    if not (0.0 < v < 1.0):
        raise ValueError(f"{name} must be strictly between 0 and 1, got {v}")
    return v

Type guard

def in_open_unit_interval(v) -> bool:
    return isinstance(v, float) and 0.0 < v < 1.0

Try / catch

try:
    component._param.check()
except ValueError as e:
    logger.error('Validation: %s (field identified by prefix only; value not shown)', e)
    raise

Prevention

When it happens

Trigger: A parameter validated with check_open_unit_interval is passed 0 or 1 (boundary values are excluded), an int like 1 (type name 'int' fails even if 0 < 1), a string "0.5", or a negative/ >1 number. Fires during the component check() pass when the canvas is saved or executed.

Common situations: Users copying a value that worked for a [0,1]-closed-interval field (check_decimal_float) into an open-interval field; setting diversity/nucleus-sampling knobs to 1 or 0 intending 'fully on/off'; string-typed values from hand-edited JSON.

Related errors


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