{"record":{"id":"24b7f7be1a7dc611","repo":"HumanSignal/label-studio","slug":"all-tasks-are-empty-none","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/serializers.py","lineNumber":525,"sourceCode":"\n    @property\n    def project(self):\n        return self.context.get('project')\n\n    @staticmethod\n    def format_error(i, detail, item):\n        if len(detail) == 1:\n            code = f' {detail[0].code}' if detail[0].code != 'invalid' else ''\n            return f'Error{code} at item {i}: {detail[0]} :: {item}'\n        else:\n            errors = ', '.join(detail)\n            codes = [d.code for d in detail]\n            return f'Errors {codes} at item {i}: {errors} :: {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({api_settings.NON_FIELD_ERRORS_KEY: 'not a list'}, code='not_a_list')\n\n        if not self.allow_empty and len(data) == 0:\n            if self.parent and self.partial:\n                raise SkipField()\n            raise ValidationError({api_settings.NON_FIELD_ERRORS_KEY: 'empty'}, code='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.child.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","sourceCodeStart":507,"sourceCodeEnd":543,"githubUrl":"https://github.com/HumanSignal/label-studio/blob/0b49e9b53917880baf1dd85d574fe5541a9aafb2/label_studio/tasks/serializers.py#L507-L543","documentation":"Raised by TaskListSerializer.to_internal_value (the bulk task import serializer) when the entire submitted data payload is null. Since there are no tasks to validate at all, the serializer fails fast with 'All tasks are empty (None)' instead of iterating items.","triggerScenarios":"POSTing to /api/projects/<id>/import or /api/tasks/ with a JSON body whose tasks/data key is explicitly null, or a form/file upload that resolves to None (e.g., missing upload file field decoded to null).","commonSituations":"API clients sending {\"tasks\": null}; CSV/JSON file upload where the file field name is wrong so the parsed content is None; scripts that serialize an empty/undefined variable to null instead of an array; ETL jobs with upstream data loss.","solutions":["Ensure the request body contains a non-null list of tasks, e.g. [{\"data\": {...}}, ...]","Check your client code for undefined variables being JSON.stringify'd as null before sending","Verify the upload file field name and that the file actually parsed (JSON/CSV) to a list","If data may legitimately be empty, guard client-side before calling the API"],"exampleFix":"// before\nawait fetch(`/api/projects/${id}/import`, { method: 'POST', body: JSON.stringify({ tasks: tasksOrNull }) });\n// after\nif (!Array.isArray(tasks)) throw new Error('tasks must be a non-null list');\nawait fetch(`/api/projects/${id}/import`, { method: 'POST', body: JSON.stringify({ tasks }) });","handlingStrategy":"type-guard","validationCode":"function assertTasksList(tasks) {\n  if (tasks === null || tasks === undefined) throw new Error('tasks payload is null');\n  if (!Array.isArray(tasks)) throw new Error('tasks must be an array');\n  if (tasks.length === 0) console.warn('importing zero tasks');\n}","typeGuard":"function isNonNullArray(v) {\n  return Array.isArray(v) && v !== null;\n}","tryCatchPattern":"try {\n  await importTasks(projectId, tasks);\n} catch (e) {\n  if (e.response?.data?.non_field_errors?.[0] === 'All tasks are empty (None)') {\n    console.error('Payload was null — check data extraction step');\n  } else throw e;\n}","preventionTips":["Validate request body before sending (non-null, non-undefined)","Avoid JSON.stringify(undefined) which produces undefined/null fields","Check file upload field names match what the server expects","Log serialized payloads in CI to catch null regressions"],"tags":["validation","null-payload","bulk-import","tasks"],"backgroundTag":"null-request-payload","analyzedSha":"0b49e9b53917880baf1dd85d574fe5541a9aafb2","analyzedAt":"2026-08-29T00:39:52.578Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}