{"record":{"id":"5ba348af4aff882f","repo":"infiniflow/ragflow","slug":"not-supported-should-be-0-or-positive-integer","errorCode":null,"errorMessage":" {} not supported, should be 0 or positive integer","messagePattern":" (.+?) not supported, should be 0 or positive integer","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/component/base.py","lineNumber":266,"sourceCode":"                    raise ValueError(\"Please check runtime conf, {} = {} does not match user-parameter restriction\".format(variable, value))\n\n            elif variable in validation_json:\n                self._validate_param(attr, validation_json)\n\n    @staticmethod\n    def check_string(param, description):\n        if type(param).__name__ not in [\"str\"]:\n            raise ValueError(description + \" {} not supported, should be string type\".format(param))\n\n    @staticmethod\n    def check_empty(param, description):\n        if not param:\n            raise ValueError(description + \" does not support empty value.\")\n\n    @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):","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/component/base.py#L248-L284","documentation":"check_nonnegative_integer raises when a param is not an int type (note: it accepts the legacy name 'long') or is negative. Enforces counts, limits, and sizes that may be zero but not negative.","triggerScenarios":"A component check() calling check_nonnegative_integer(param, description) where param is e.g. -1, a float like 1.5, or a string like \"10\" — top_n, retries, timeout counts, memory limits.","commonSituations":"Config forms returning strings for numeric inputs; passing -1 as a 'no limit' sentinel the validator does not accept; floats leaking in from computed values; YAML unquoted values parsing oddly.","solutions":["Set the value to an int >= 0 (if 'unlimited' semantics are needed, use the component's documented max or a large int, not -1).","Coerce types at the boundary: int(value) before it reaches the component.","Fix UI inputs to emit proper numeric types.","Check for float drift in computed configs and round/cast to int."],"exampleFix":"# before\nparams = {\"top_n\": \"5\"}   # string -> fails\n# before\nparams = {\"top_n\": -1}    # negative -> fails\n\n# after\nparams = {\"top_n\": 5}","handlingStrategy":"type-guard","validationCode":"def to_nonneg_int(v, field):\n    if isinstance(v, bool) or not isinstance(v, int):\n        raise ValueError(f'{field} must be int')\n    if v < 0:\n        raise ValueError(f'{field} must be >= 0')\n    return v","typeGuard":"def is_nonneg_int(v) -> bool:\n    return isinstance(v, int) and not isinstance(v, bool) and v >= 0","tryCatchPattern":"try:\n    param.check()\nexcept ValueError as e:\n    if 'should be 0 or positive integer' in str(e):\n        conf[field] = max(0, int(conf[field]))  # coerce then re-check\n        param.update(conf); param.check()","preventionTips":["Use numeric form inputs (type=number, min=0) for these params.","Cast with int() at the config boundary; remember bool passes isinstance(v, int).","Do not use -1 as an 'unlimited' sentinel where this validator runs."],"tags":["canvas","type-validation","parameter-validation","integer"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}