{"record":{"id":"3568a0295561d82a","repo":"HumanSignal/label-studio","slug":"data-data-key-data-value-is-of-type-type","errorCode":null,"errorMessage":"data['{data_key}']={data_value} is of type '{type}', but the object tag {data_type} expects the following types: {expected_types}","messagePattern":"data\\['(.+?)'\\]=(.+?) is of type '(.+?)', but the object tag (.+?) expects the following types: (.+?)","errorType":"validation","errorClass":"ValidationError","httpStatus":400,"severity":"error","filePath":"label_studio/tasks/validation.py","lineNumber":85,"sourceCode":"\n            if '.' in data_key:\n                keys = data_key.split('.')\n                try:\n                    data_item = reduce(getitem, keys, data)\n                except KeyError:\n                    raise ValidationError('\"{data_key}\" key is expected in task data'.format(data_key=data_key))\n            else:\n                if data_key not in data:\n                    raise ValidationError('\"{data_key}\" key is expected in task data'.format(data_key=data_key))\n                data_item = data[data_key]\n\n            if is_array:\n                expected_types = (list,)\n            else:\n                expected_types = _DATA_TYPES.get(data_type, (str,))\n\n            if not isinstance(data_item, tuple(expected_types)):\n                raise ValidationError(\n                    \"data['{data_key}']={data_value} is of type '{type}', \"\n                    'but the object tag {data_type} expects the following types: {expected_types}'.format(\n                        data_key=data_key,\n                        data_value=data_item,\n                        type=type(data_item).__name__,\n                        data_type=data_type,\n                        expected_types=[e.__name__ for e in expected_types],\n                    )\n                )\n\n        return data\n\n    @staticmethod\n    def check_data_and_root(project, data, dict_is_root=False):\n        \"\"\"Check data consistent and data is dict with task or dict['task'] is task\n\n        :param project:\n        :param data:","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/HumanSignal/label-studio/blob/0b49e9b53917880baf1dd85d574fe5541a9aafb2/label_studio/tasks/validation.py#L67-L103","documentation":"After finding the required key, check_data validates its value's Python type against _DATA_TYPES, which maps each labeling-config object tag (Text, Image, HyperText, ...) to allowed types. This error means the key exists but its value's type is not allowed for the tag used in the config, e.g. a dict where Text expects str/int/float/list. Bracketed array tags (from Repeater, is_array=True) require a list.","triggerScenarios":"Config <Image value=\"$img\"/> with data {'img': {'url': ...}} (dict, only str|list allowed); <Text value=\"$text\"/> with {'text': {'a': 1}}; using $var inside a Repeater (e.g. $images) while the value is a single string instead of a list.","commonSituations":"Passing structured/nested objects where plain strings are expected; numbers-as-strings or booleans for Header/Text; giving a single item where the config's Repeater/bracket syntax expects an array; new tag types added to the config but not covered in _DATA_TYPES default to str-only.","solutions":["Coerce the value to a type allowed by the tag (e.g. str(value) for Text, list for Repeater variables)","Check _DATA_TYPES to see the accepted types for the tag used in your config","If the config uses a bracketed/Repeater variable ($items), wrap the value in a list","If you need richer payloads, use a tag that accepts dict (Table, TimeSeries) or upload the object as a file/reference"],"exampleFix":"// before\n{'data': {'text': {'body': 'hello'}}}  # <Text value=\"$text\"/>\n// after\n{'data': {'text': str({'body': 'hello'})}}  # or use a Table/TimeSeries tag that accepts dict","handlingStrategy":"type-guard","validationCode":"_DATA_TYPES = {'Text': (str, int, float, list), 'Image': (str, list)}\nfor key, tag in project.data_types.items():\n    key = key.split('[')[0]\n    if key in data and not isinstance(data[key], tuple(_DATA_TYPES.get(tag, (str,)))):\n        raise TypeError(f'{key} must match tag {tag}')","typeGuard":"def matches_tag(value, tag, is_array=False):\n    expected = (list,) if is_array else tuple(_DATA_TYPES.get(tag, (str,)))\n    return isinstance(value, expected)","tryCatchPattern":"try:\n    import_tasks(tasks)\nexcept ValidationError as e:\n    m = re.search(r\"data\\['(.+?)'\\].*tag (\\w+)\", str(e.detail[0]))\n    if m:\n        coerce_value(tasks, m.group(1), m.group(2))","preventionTips":["Consult _DATA_TYPES when choosing a tag for a field","Wrap values in lists for Repeater/bracket ($items) variables","Avoid passing dicts to Text/Image-type tags; use Table/TimeSeries tags for structured data"],"tags":["validation","type-mismatch","label-config"],"backgroundTag":"schema-validation-failed","analyzedSha":"0b49e9b53917880baf1dd85d574fe5541a9aafb2","analyzedAt":"2026-08-29T00:39:52.578Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}