{"record":{"id":"8686c90e7fdf0eec","repo":"infiniflow/ragflow","slug":"not-supported-should-be-non-negative-numeric","errorCode":null,"errorMessage":" {} not supported, should be non-negative numeric","messagePattern":" (.+?) not supported, should be non-negative numeric","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/component/base.py","lineNumber":281,"sourceCode":"    @staticmethod\n    def check_nonnegative_integer(param, description):\n        if type(param).__name__ not in [\"int\", \"long\"] or param < 0:\n            raise ValueError(description + \" {} not supported, should be 0 or positive integer\".format(param))\n\n    @staticmethod\n    def check_positive_integer(param, description):\n        if type(param).__name__ not in [\"int\", \"long\"] or param <= 0:\n            raise ValueError(description + \" {} not supported, should be positive integer\".format(param))\n\n    @staticmethod\n    def check_positive_number(param, description):\n        if type(param).__name__ not in [\"float\", \"int\", \"long\"] or param <= 0:\n            raise ValueError(description + \" {} not supported, should be positive numeric\".format(param))\n\n    @staticmethod\n    def check_nonnegative_number(param, description):\n        if type(param).__name__ not in [\"float\", \"int\", \"long\"] or param < 0:\n            raise ValueError(description + \" {} not supported, should be non-negative numeric\".format(param))\n\n    @staticmethod\n    def check_decimal_float(param, description):\n        if type(param).__name__ not in [\"float\", \"int\"] or param < 0 or param > 1:\n            raise ValueError(description + \" {} not supported, should be a float number in range [0, 1]\".format(param))\n\n    @staticmethod\n    def check_boolean(param, description):\n        if type(param).__name__ != \"bool\":\n            raise ValueError(description + \" {} not supported, should be bool type\".format(param))\n\n    @staticmethod\n    def check_open_unit_interval(param, description):\n        if type(param).__name__ not in [\"float\"] or param <= 0 or param >= 1:\n            raise ValueError(description + \" should be a numeric number between 0 and 1 exclusively\")\n\n    @staticmethod\n    def check_valid_value(param, description, valid_values):","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/component/base.py#L263-L299","documentation":"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.","triggerScenarios":"A component check() calling check_nonnegative_number(param, description) with a negative value or a non-numeric type (string, None, list).","commonSituations":"Temperature-like or weight params set negative by mistake; string numerics from JSON configs; None leaking from unset optional fields that are nonetheless validated.","solutions":["Set the value to a number >= 0.","Cast string numerics to float/int at the config boundary.","If None appears, either supply a default >= 0 before check() or skip validation for genuinely optional fields.","Add quick type assertions in DSL-generation scripts."],"exampleFix":"# before\nparams = {\"weight\": \"-0.5\"}  # string AND negative\n\n# after\nparams = {\"weight\": 0.5}","handlingStrategy":"type-guard","validationCode":"def to_nonneg_number(v, field):\n    if isinstance(v, bool) or not isinstance(v, (int, float)):\n        raise ValueError(f'{field} must be numeric')\n    if v < 0:\n        raise ValueError(f'{field} must be >= 0')\n    return v","typeGuard":"def is_nonneg_number(v) -> bool:\n    return isinstance(v, (int, float)) and not isinstance(v, bool) and v >= 0","tryCatchPattern":"try:\n    param.check()\nexcept ValueError as e:\n    if 'should be non-negative numeric' in str(e):\n        conf[field] = abs(float(conf[field]))  # or fix at source\n        param.update(conf); param.check()","preventionTips":["Guard optional numeric fields against None before check().","Cast string numerics from JSON/YAML at parse time.","Add sign checks in UI inputs (min=0) for weight/score-like params."],"tags":["canvas","type-validation","parameter-validation","numeric"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}