{"record":{"id":"4942a5074a1a78c1","repo":"HumanSignal/label-studio","slug":"can-t-deserialize-tasks-due-to-errors-4942a5","errorCode":null,"errorMessage":"Can't deserialize tasks due to {errors}","messagePattern":"Can't deserialize tasks due to (.+?)","errorType":"validation","errorClass":"ValidationError","httpStatus":400,"severity":"error","filePath":"label_studio/tasks/validation.py","lineNumber":247,"sourceCode":"            except ValidationError as exc:\n                error = self.format_error(i, exc.detail, item)\n                errors.append(error)\n                # do not print to user too many errors\n                if len(errors) >= 100:\n                    errors[99] = '...'\n                    break\n            else:\n                ret.append(validated)\n                errors.append({})\n\n                if 'annotations' in item:\n                    self.annotation_count += len(item['annotations'])\n                if 'predictions' in item:\n                    self.prediction_count += len(item['predictions'])\n\n        if any(errors):\n            logger.warning(\"Can't deserialize tasks due to \" + str(errors))\n            raise ValidationError(errors)\n\n        return ret\n\n\ndef is_url(string):\n    try:\n        result = urlparse(string.strip())\n        return all([result.scheme, result.netloc])\n    except ValueError:\n        return False\n","sourceCodeStart":229,"sourceCodeEnd":258,"githubUrl":"https://github.com/HumanSignal/label-studio/blob/0b49e9b53917880baf1dd85d574fe5541a9aafb2/label_studio/tasks/validation.py#L229-L258","documentation":"After validating every item, to_internal_value aggregates any per-item ValidationError messages (formatted as 'Error ... at item i: ... :: item', capped at 100) and raises this single DRF ValidationError carrying the list of errors. It is the terminal failure for a partially-invalid import batch — no tasks are created if any item fails.","triggerScenarios":"Any batch where at least one item fails TaskValidator.validate — missing 'data' key, wrong data types vs the labeling config, bad annotation/prediction structure, non-dict task root, etc.","commonSituations":"Bulk imports mixing valid and invalid rows from a CSV/JSON conversion; items that reference data keys absent from the project's labeling config; imports built from other tools' export formats that don't match Label Studio's task schema.","solutions":["Read the errors list in the response: each entry names the item index and the exact problem","Fix the offending items (typically missing/wrong-typed keys under 'data') and re-import the full batch","Compare your data keys against the project's labeling config (project.data_types) — every required data key must exist with an allowed type","Pre-validate locally by replicating the checks: dict root, 'data' present, expected types per config","Import in smaller chunks to isolate which items are invalid"],"exampleFix":"// before\n[{\"text\": \"missing data wrapper\"}]\n// after\n[{\"data\": {\"text\": \"wrapped under data\"}}]","handlingStrategy":"validation","validationCode":"for i, task in enumerate(tasks):\n    assert isinstance(task, dict), f'item {i} not a dict'\n    assert 'data' in task, f'item {i} missing data'\n    for key in required_data_keys:  # from project.data_types\n        assert key in task['data'], f'item {i} missing data key {key}'","typeGuard":null,"tryCatchPattern":"try:\n    client.import_tasks(id=project_id, tasks=tasks)\nexcept LabelStudioError as e:\n    for err in getattr(e, 'detail', [str(e)]):\n        print(err)  # each names item index and the exact problem\n    raise","preventionTips":["Parse the per-item error strings in the response — they include the item index","Cross-check data keys against the project's labeling config before import","Import in chunks to isolate failing items","Keep a schema test for your export-to-Label-Studio converter"],"tags":["validation","task-import","batch-errors","rest-api"],"backgroundTag":"schema-validation-failed","analyzedSha":"0b49e9b53917880baf1dd85d574fe5541a9aafb2","analyzedAt":"2026-08-29T00:39:52.578Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}