{"record":{"id":"87d1399c7d889d98","repo":"HumanSignal/label-studio","slug":"load-tasks-no-tasks-added","errorCode":null,"errorMessage":"load_tasks: No tasks added","messagePattern":"load_tasks: No tasks added","errorType":"validation","errorClass":"ValidationError","httpStatus":400,"severity":"error","filePath":"label_studio/data_import/uploader.py","lineNumber":239,"sourceCode":"                found_formats,\n                tasks,\n                file_upload_ids,\n                could_be_tasks_list,\n            ) = tasks_from_url(file_upload_ids, project_import.project, user, url, could_be_tasks_list)\n            if could_be_tasks_list:\n                project_import.could_be_tasks_list = True\n                project_import.save(update_fields=['could_be_tasks_list'])\n\n    elif project_import.tasks:\n        tasks = project_import.tasks\n\n    # check is data root is list\n    if not isinstance(tasks, list):\n        raise ValidationError('load_tasks: Data root must be list')\n\n    # empty tasks error\n    if not tasks:\n        raise ValidationError('load_tasks: No tasks added')\n\n    check_max_task_number(tasks)\n    return tasks, file_upload_ids, found_formats, list(data_keys)\n\n\ndef load_tasks_for_async_import_streaming(project_import, user, batch_size=1000):\n    \"\"\"Load tasks from different types of request.data / request.files saved in project_import model,\n    yielding tasks in batches to reduce memory usage\"\"\"\n    from django.conf import settings\n\n    if not batch_size:\n        batch_size = settings.IMPORT_BATCH_SIZE\n\n    all_file_upload_ids = []\n    all_found_formats = {}\n    all_data_keys = set()\n\n    if project_import.file_upload_ids:","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/HumanSignal/label-studio/blob/0b49e9b53917880baf1dd85d574fe5541a9aafb2/label_studio/data_import/uploader.py#L221-L257","documentation":"ValidationError raised by load_tasks_for_async_import in label_studio/data_import/uploader.py. After confirming the payload is a list, it must be non-empty; an empty list means there is nothing to import, so the async import fails with 'load_tasks: No tasks added'.","triggerScenarios":"async_import_background -> load_tasks_for_async_import with tasks == [] — e.g. an uploaded JSON file containing [], a CSV with only headers, a URL returning an empty array, or inline tasks submitted as [].","commonSituations":"Exporting zero rows from a filtered source; CSV where the parser drops all rows (encoding issues, wrong delimiter); a script uploading an empty placeholder before data is ready; URL import pointing at an empty result.","solutions":["Check the source file/URL actually contains records before importing.","Inspect the CSV: headers-only means no data rows — export with data or fix the delimiter/encoding.","Fix upstream export filters that produced an empty dataset.","Only call the import API once your payload has at least one task."],"exampleFix":"// before\nconst tasks = await exportAll(); // []\nawait importTasks(tasks); // error\n\n// after\nif (tasks.length === 0) throw new Error('Nothing to export');\nawait importTasks(tasks);","handlingStrategy":"validation","validationCode":"import json\npayload = json.load(open(path))\nif not isinstance(payload, list) or len(payload) == 0:\n    raise ValueError('import payload is empty — export produced no tasks')\nimport_tasks(payload)","typeGuard":"def has_tasks(payload):\n    return isinstance(payload, list) and len(payload) > 0","tryCatchPattern":"try:\n    import_tasks(payload)\nexcept ValidationError as e:\n    if 'No tasks added' in str(e):\n        log.error('source dataset empty — check export filters/CSV rows')\n    else:\n        raise","preventionTips":["Check record count of your export before importing (rows > 0).","Verify CSVs have data rows, not just headers, and the delimiter/encoding parses correctly.","For URL imports, curl the endpoint and confirm a non-empty array.","Guard scripts: skip the import call entirely when the payload is empty."],"tags":["django","validation","empty-input","import-format","label-studio"],"backgroundTag":"empty-payload-import","analyzedSha":"0b49e9b53917880baf1dd85d574fe5541a9aafb2","analyzedAt":"2026-08-29T00:39:52.578Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}