infiniflow/ragflow · error · ValueError

{} not supported, should be a float number in range [0, 1]

Error message

 {} not supported, should be a float number in range [0, 1]

What it means

Raised by ComponentParamBase.check_decimal_float in agent/component/base.py when a component parameter expected to be a probability-like number is not a float/int (by exact type name) or falls outside [0, 1]. It is a configuration-validation error thrown from the parameter check() phase of agent canvas components. The message interpolates the offending value and the caller-supplied description, e.g. '[SomeComponent] Similarity threshold 1.5 not supported, should be a float number in range [0, 1]'.

Source

Thrown at agent/component/base.py:286

    @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):
        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):

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Set the parameter to an unquoted number between 0 and 1 in the component config (e.g. 0.75, not "0.75" and not 75)
  2. If loading config from JSON/JSONB, coerce with float(value) before assigning to the component param
  3. Check the error's description prefix to identify which component and which parameter failed, then fix that field in the canvas JSON
  4. If the value legitimately exceeds 1 (e.g. a count), you are using the wrong validator field — the parameter belongs to a different check method

Example fix

# before (canvas JSON or param assignment)
"similarity": "0.75"   # str -> raises

# after
"similarity": 0.75      # float in [0, 1]
Defensive patterns

Strategy: validation

Validate before calling

def as_decimal_float(v, name):
    if isinstance(v, bool) or not isinstance(v, (int, float)):
        raise TypeError(f"{name} must be a number, got {type(v).__name__}")
    v = float(v)
    if not (0.0 <= v <= 1.0):
        raise ValueError(f"{name} must be within [0, 1], got {v}")
    return v

threshold = as_decimal_float(canvas_param['threshold'], 'threshold')

Type guard

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

Try / catch

try:
    component._param.check()
except ValueError as e:
    logger.error('Component param validation failed: %s', e)
    return handle_invalid_config(e)

Prevention

When it happens

Trigger: Any agent component whose check() calls check_positive... check_decimal_float(param, desc) with: a string like "0.75" (JSON deserialization kept it a str), a bool (type name 'bool' is rejected), None, a number > 1 (e.g. top_n, threshold=5), or a negative number. Triggered when the canvas is saved/run and the component's _param.check() executes.

Common situations: Hand-edited agent canvas JSON where a threshold (similarity, temperature-like knob, overlap ratio) is stored as a string; frontend sending form values as strings; passing a percentage (0-100) instead of a fraction (0-1); copy-pasting config from another component that used a different scale.

Related errors


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