{"record":{"id":"8b418085dfae54ce","repo":"HumanSignal/label-studio","slug":"e-detail-0-assume-item-data-task-root-wi","errorCode":null,"errorMessage":"{e.detail[0]} [assume: item[\"data\"] = task root with values]","messagePattern":"(.+?) \\[assume: item\\[\"data\"\\] = task root with values\\]","errorType":"validation","errorClass":"ValidationError","httpStatus":400,"severity":"warning","filePath":"label_studio/tasks/validation.py","lineNumber":113,"sourceCode":"\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:\n        :param dict_is_root:\n        :return:\n        \"\"\"\n        try:\n            TaskValidator.check_data(project, data)\n        except ValidationError as e:\n            if dict_is_root:\n                raise ValidationError(e.detail[0] + ' [assume: item as is = task root with values] ')\n            else:\n                raise ValidationError(e.detail[0] + ' [assume: item[\"data\"] = task root with values]')\n\n    @staticmethod\n    def check_allowed(task):\n        # task is required\n        if 'data' not in task:\n            return False\n\n        # everything is ok\n        return True\n\n    @staticmethod\n    def raise_if_wrong_class(task, key, class_def):\n        if key in task and not isinstance(task[key], class_def):\n            if isinstance(class_def, tuple):\n                class_def = ' or '.join([c.__name__ for c in class_def])\n            else:\n                class_def = class_def.__name__\n            raise ValidationError('Task[{key}] must be {class_def}'.format(key=key, class_def=class_def))","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/HumanSignal/label-studio/blob/0b49e9b53917880baf1dd85d574fe5541a9aafb2/label_studio/tasks/validation.py#L95-L131","documentation":"The dict_is_root=False counterpart of [224]: check_data_and_root re-raises the inner check_data message with the appended hint \" [assume: item[\\\"data\\\"] = task root with values]\". This is the default path when an item HAS a 'data' key (validate -> raise_if_wrong_class('data',(dict,list)) -> check_data_and_root(project, task['data'])), meaning the value of item['data'] failed validation. The hint tells the user the payload inside item['data'] was validated as the task root.","triggerScenarios":"Importing {'data': {...}} where the inner dict is None, missing a required config key, or has a value of the wrong type — e.g. {'data': {'sentence': 'x'}} with config referencing $text, or {'data': None}.","commonSituations":"API imports via /api/tasks or project import with wrapped payloads; SDK import_tasks calls; post-edit saves through TaskSerializer.validate where instance.data parsing succeeded but config validation failed.","solutions":["Fix the issue described in the message prefix (missing key / wrong type / None data) inside item['data']","Verify the keys in item['data'] exactly match the $variables in the labeling config","Run a local pre-check: for each config key, assert key in payload and isinstance matches _DATA_TYPES","If 'data' was meant to be the root itself, restructure to the bare-dict form (dict_is_root path) deliberately"],"exampleFix":"// before\n{'data': {'sentence': 'hello'}}  # config: <Text value=\"$text\"/>\n// after\n{'data': {'text': 'hello'}}","handlingStrategy":"validation","validationCode":"def validate_wrapped(task, data_types):\n    data = task.get('data')\n    if not isinstance(data, dict):\n        raise ValueError('task[\"data\"] must be a dict')\n    for key, tag in data_types.items():\n        key = key.split('[')[0]\n        if '.' not in key and key not in data:\n            raise ValueError(f'data missing {key}')","typeGuard":"def has_valid_data(task):\n    return isinstance(task, dict) and isinstance(task.get('data'), dict)","tryCatchPattern":"try:\n    import_tasks(tasks)\nexcept ValidationError as e:\n    msg = str(e.detail[0])\n    if 'item[\"data\"] = task root' in msg:\n        fix_inner_data(msg, tasks)  # parse prefix and repair the inner dicts","preventionTips":["Treat item['data'] as the task root: it must satisfy all config variables","Pre-validate inner dicts against project.data_types before every import","Keep one payload convention (wrapped) across all import tooling"],"tags":["validation","task-import","label-studio"],"backgroundTag":"schema-validation-failed","analyzedSha":"0b49e9b53917880baf1dd85d574fe5541a9aafb2","analyzedAt":"2026-08-29T00:39:52.578Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}