{"record":{"id":"81d5d213b70a530f","repo":"HumanSignal/label-studio","slug":"all-tasks-are-empty-none-81d5d2","errorCode":null,"errorMessage":"All tasks are empty (None)","messagePattern":"All tasks are empty \\(None\\)","errorType":"validation","errorClass":"ValidationError","httpStatus":400,"severity":"error","filePath":"label_studio/tasks/validation.py","lineNumber":216,"sourceCode":"            self.check_data_and_root(self.project, task, dict_is_root=True)\n            task = {'data': task}\n\n        return task\n\n    @staticmethod\n    def format_error(i, detail, item):\n        if len(detail) == 1:\n            code = (str(detail[0].code + ' ')) if detail[0].code != 'invalid' else ''\n            return 'Error {code} at item {i}: {detail} :: {item}'.format(code=code, i=i, detail=detail[0], item=item)\n        else:\n            errors = ', '.join(detail)\n            codes = str([d.code for d in detail])\n            return 'Errors {codes} at item {i}: {errors} :: {item}'.format(codes=codes, i=i, errors=errors, item=item)\n\n    def to_internal_value(self, data):\n        \"\"\"Body of run_validation for all data items\"\"\"\n        if data is None:\n            raise ValidationError('All tasks are empty (None)')\n\n        if not isinstance(data, list):\n            raise ValidationError('data is not a list')\n\n        if len(data) == 0:\n            raise ValidationError('data is empty')\n\n        ret, errors = [], []\n        self.annotation_count, self.prediction_count = 0, 0\n        for i, item in enumerate(data):\n            try:\n                validated = self.validate(item)\n            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] = '...'","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/HumanSignal/label-studio/blob/0b49e9b53917880baf1dd85d574fe5541a9aafb2/label_studio/tasks/validation.py#L198-L234","documentation":"TaskValidator.to_internal_value raises this when the whole payload passed to task import is None. Since there is nothing to iterate over, the validator fails fast with this message instead of the more specific per-item errors.","triggerScenarios":"POSTing an import request with an empty body (no JSON), or with explicit JSON null as the body; calling run_validation(None) directly; an HTTP client sending a request whose parsed body yields None (e.g. wrong Content-Type with empty data).","commonSituations":"API clients forgetting to attach a body; scripts reading task data from a file that turns out empty and passing the parsed None; SDK calls where the tasks argument was omitted or a variable referencing an unloaded value is None.","solutions":["Send a JSON array of task objects as the request body, e.g. [{\"data\": {...}}]","Check the upstream variable producing the payload and fix why it is None","Ensure Content-Type is application/json and the body is actually transmitted","Guard in client code: if not tasks: raise ValueError('no tasks to import') before calling the API"],"exampleFix":"// before\nrequests.post(url, headers=headers)  # no body -> data is None\n// after\nrequests.post(url, json=[{\"data\": {\"text\": \"hi\"}}], headers=headers)","handlingStrategy":"validation","validationCode":"if tasks is None:\n    raise ValueError('tasks payload is None; provide a non-empty JSON array of task objects')","typeGuard":"def is_valid_payload(tasks):\n    return isinstance(tasks, list) and len(tasks) > 0","tryCatchPattern":"try:\n    client.import_tasks(id=project_id, tasks=tasks)\nexcept LabelStudioError as e:\n    if 'All tasks are empty (None)' in str(e):\n        raise ValueError('No task payload was sent; check the variable feeding the import call') from e\n    raise","preventionTips":["Guard against None payload before calling the import API","Verify the request body is actually attached (json= or data=) and Content-Type is application/json","Check the file/variable upstream is not empty or failed to load","Log the payload length before import for observability"],"tags":["validation","task-import","null-input","rest-api"],"backgroundTag":"empty-request-body","analyzedSha":"0b49e9b53917880baf1dd85d574fe5541a9aafb2","analyzedAt":"2026-08-29T00:39:52.578Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}