{"record":{"id":"e2fef00955189ba4","repo":"infiniflow/ragflow","slug":"not-supported-should-be-one-of","errorCode":null,"errorMessage":" {} not supported, should be one of {}","messagePattern":" (.+?) not supported, should be one of (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/component/base.py","lineNumber":306,"sourceCode":"    @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):\n        if param not in valid_values:\n            raise ValueError(description + \" {} is not supported, it should be in {}\".format(param, valid_values))\n\n    @staticmethod\n    def check_defined_type(param, description, types):\n        if type(param).__name__ not in types:\n            raise ValueError(description + \" {} not supported, should be one of {}\".format(param, types))\n\n    @staticmethod\n    def check_and_change_lower(param, valid_list, description=\"\"):\n        if type(param).__name__ != \"str\":\n            raise ValueError(description + \" {} not supported, should be one of {}\".format(param, valid_list))\n\n        lower_param = param.lower()\n        if lower_param in valid_list:\n            return lower_param\n        else:\n            raise ValueError(description + \" {} not supported, should be one of {}\".format(param, valid_list))\n\n    @staticmethod\n    def _greater_equal_than(value, limit):\n        return value >= limit - settings.FLOAT_ZERO\n\n    @staticmethod\n    def _less_equal_than(value, limit):","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/component/base.py#L288-L324","documentation":"Raised by ComponentParamBase.check_defined_type in agent/component/base.py when the value's exact type name (type(param).__name__) is not in the caller-provided types list of type-name strings. It is a type whitelist check, stricter than isinstance: subclasses with different __name__s and JSON-deserialized primitives that kept string form will fail. The message lists the offending value and the accepted type names.","triggerScenarios":"A component check() calls check_defined_type(self.some_param, desc, ['str','list','dict']) and the value is e.g. an int where a str was expected, a dict where a list was expected, or a stringified JSON ('[\"a\"]') that was never parsed. Fires when the canvas component parameters are validated.","commonSituations":"Frontend sends JSON fields as strings; nested config edited by hand in the canvas JSON where a list became a scalar; version changes that switched a parameter's accepted type; None defaults not replaced.","solutions":["Match the parameter's Python type to one of the names printed in the message (e.g. 'str', 'list', 'dict')","Parse stringified JSON before validation: json.loads(value) if isinstance(value, str) and value.startswith(('[','{'))","Use the description prefix in the message to locate the exact component field to fix in the canvas configuration"],"exampleFix":"# before\nself.urls = \"[\\\"https://a\\\"]\"  # str, but types=[\"list\"]\n\n# after\nimport json\nself.urls = json.loads(self.urls)  # actual list","handlingStrategy":"type-guard","validationCode":"def coerce_to_type(v, type_names):\n    import json\n    if type(v).__name__ in type_names:\n        return v\n    if isinstance(v, str) and v.startswith(('[', '{')):\n        try:\n            parsed = json.loads(v)\n            if type(parsed).__name__ in type_names:\n                return parsed\n        except json.JSONDecodeError:\n            pass\n    if type_names == ['str']:\n        return str(v)\n    raise TypeError(f\"expected one of {type_names}, got {type(v).__name__}\")","typeGuard":"def matches_defined_types(v, type_names) -> bool:\n    return type(v).__name__ in type_names","tryCatchPattern":"try:\n    component._param.check()\nexcept ValueError as e:\n    logger.error('Type validation failed: %s', e)\n    raise","preventionTips":["Parse JSON strings into real objects before assigning them to component params","Keep the declared type stable in the frontend form (a list field stays a list)","Prefer isinstance-based checks in your own code; remember this validator compares type names exactly"],"tags":["validation","agent-component","type-check","python"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}