{"record":{"id":"4ae725c7f140a2ec","repo":"infiniflow/ragflow","slug":"not-supported-should-be-string-type","errorCode":null,"errorMessage":"{} not supported, should be string type","messagePattern":"(.+?) not supported, should be string type","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/component/base.py","lineNumber":256,"sourceCode":"                validation_dict = validation_json[default_section][variable]\n                value = getattr(param_obj, variable)\n                value_legal = False\n\n                for op_type in validation_dict:\n                    if self.func[op_type](value, validation_dict[op_type]):\n                        value_legal = True\n                        break\n\n                if not value_legal:\n                    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):","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/component/base.py#L238-L274","documentation":"check_string is a param validator used inside component check() methods: it raises ValueError when the param's runtime type is not exactly 'str' (bool/int/None etc. all fail). The message embeds the caller-provided description plus the offending value.","triggerScenarios":"A component check() calling check_string(param, description) where param is a non-string — e.g. a model id passed as int, None from an unset optional field, or a bool from a config form.","commonSituations":"YAML/JSON configs coercing values (unquoted yes/no -> bool, numeric-looking ids -> int); optional fields left as None but validated as required strings; API callers sending typed values where strings are expected.","solutions":["Wrap the value in a string or quote it in YAML/JSON so it deserializes as str.","Provide the missing value if it is None because the field was never set.","In component code, gate check_string on the field being set if it is genuinely optional.","Validate types client-side before submitting the canvas/config."],"exampleFix":"# before\nconf = {\"api_key\": 12345}\n\n# after\nconf = {\"api_key\": \"12345\"}","handlingStrategy":"type-guard","validationCode":"def ensure_strings(conf, string_fields):\n    for f in string_fields:\n        if f in conf and conf[f] is not None:\n            conf[f] = str(conf[f])\n    return conf","typeGuard":"def is_str(v) -> bool:\n    return type(v).__name__ == 'str'  # exact match, excludes bool/int/None","tryCatchPattern":"try:\n    param.check()\nexcept ValueError as e:\n    if 'should be string type' in str(e):\n        field = parse_field(str(e))\n        conf[field] = str(conf[field])\n        param.update(conf); param.check()","preventionTips":["Quote string-like values in YAML configs to prevent type coercion.","Apply str() coercion at API boundaries for fields documented as strings.","Note that check_string rejects bool and None too — not just numbers."],"tags":["canvas","type-validation","parameter-validation","string"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}