{"record":{"id":"b9b053d10f66884f","repo":"HumanSignal/label-studio","slug":"e-detail-0-assume-item-as-is-task-root-with","errorCode":null,"errorMessage":"{e.detail[0]} [assume: item as is = task root with values] ","messagePattern":"(.+?) \\[assume: item as is = task root with values\\] ","errorType":"validation","errorClass":"ValidationError","httpStatus":400,"severity":"warning","filePath":"label_studio/tasks/validation.py","lineNumber":111,"sourceCode":"                    )\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:\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:","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/HumanSignal/label-studio/blob/0b49e9b53917880baf1dd85d574fe5541a9aafb2/label_studio/tasks/validation.py#L93-L129","documentation":"check_data_and_root wraps check_data: when the inner validation fails and dict_is_root=True, it re-raises the original message plus the hint \" [assume: item as is = task root with values] \". This variant fires when the submitted item had NO 'data' field, so Label Studio treated the item itself as the data payload (validate()'s else-branch calls check_data_and_root(project, task, dict_is_root=True)), and that data also failed validation.","triggerScenarios":"Importing an item like {'text': 'hello'} (no 'data' key) where 'text' itself fails check_data (missing required config key, wrong type, etc.); validate() falls to the else-branch and validates the item as data with dict_is_root=True.","commonSituations":"Bulk imports that submit raw data dicts without wrapping in {'data': ...}; users assuming top-level keys like annotations/predictions can sit beside unwrapped data; mixed batches where some items are wrapped and some are not.","solutions":["Read the prefix of the message (the e.detail[0] part) to find the real validation failure, then fix that in the item","Prefer wrapping payloads explicitly: {'data': {...}} so the root-assumption path is never taken","Ensure the unwrapped item's keys match the config variables and their expected types","Normalize the whole batch to one shape (all wrapped or all bare data dicts) before import"],"exampleFix":"// before\nimport_tasks([{'text': 123}])  # config <Text value=\"$text\"/> but Text won't accept... wait, 123 is fine; e.g. {'img': {'url': 'x'}}\n// after\nimport_tasks([{'data': {'img': 'x'}}])  # or fix the inner failure indicated before the hint","handlingStrategy":"validation","validationCode":"def is_wrapped(item):\n    return isinstance(item, dict) and 'data' in item\nbad = [i for i, t in enumerate(items) if not is_wrapped(t)]\nif bad:\n    items = [{'data': t} if isinstance(t, dict) else {'data': {}} for t in items]","typeGuard":"def is_bare_data_dict(item):\n    return isinstance(item, dict) and 'data' not in item","tryCatchPattern":"try:\n    import_tasks(items)\nexcept ValidationError as e:\n    msg = str(e.detail[0])\n    if 'item as is = task root' in msg:\n        items = [{'data': it} for it in items]  # switch to explicit wrapping\n        import_tasks(items)","preventionTips":["Always use the explicit {'data': ...} wrapper in imports","Mixing wrapped and bare items in one batch makes root-assumption errors hard to read","Read the message prefix before the '[assume:' hint — it names the real failure"],"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"}