{"record":{"id":"5654b9f0a1e3f4ac","repo":"HumanSignal/label-studio","slug":"maximum-task-number-is-settings-tasks-max-number","errorCode":null,"errorMessage":"Maximum task number is {settings.TASKS_MAX_NUMBER}, current task number is {len(tasks)}","messagePattern":"Maximum task number is (.+?), current task number is (.+?)","errorType":"validation","errorClass":"ValidationError","httpStatus":400,"severity":"error","filePath":"label_studio/data_import/uploader.py","lineNumber":47,"sourceCode":"\n\ndef csv_generate_header(file):\n    \"\"\"Generate column names for headless csv file\"\"\"\n    file.seek(0)\n    names = []\n    line = file.readline()\n\n    num_columns = len(line.split(b',' if isinstance(line, bytes) else ','))\n    for i in range(num_columns):\n        names.append('column' + str(i + 1))\n    file.seek(0)\n    return names\n\n\ndef check_max_task_number(tasks):\n    # max tasks\n    if len(tasks) > settings.TASKS_MAX_NUMBER:\n        raise ValidationError(\n            f'Maximum task number is {settings.TASKS_MAX_NUMBER}, current task number is {len(tasks)}'\n        )\n\n\ndef check_tasks_max_file_size(value):\n    if value >= settings.TASKS_MAX_FILE_SIZE:\n        raise ValidationError(\n            f'Maximum total size of all files is {settings.TASKS_MAX_FILE_SIZE} bytes, current size is {value} bytes'\n        )\n\n\ndef check_extensions(files):\n    for filename, file_obj in files.items():\n        _, ext = os.path.splitext(file_obj.name)\n        if ext.lower() not in settings.SUPPORTED_EXTENSIONS:\n            raise ValidationError(f'{ext} extension is not supported')\n\n","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/HumanSignal/label-studio/blob/0b49e9b53917880baf1dd85d574fe5541a9aafb2/label_studio/data_import/uploader.py#L29-L65","documentation":"django.core.exceptions.ValidationError raised by check_max_task_number in label_studio/data_import/uploader.py. Label Studio enforces settings.TASKS_MAX_NUMBER as a hard cap on the number of tasks in a single import; if the task list exceeds that cap, import is rejected before any tasks are created. The limit protects the database and UI from unbounded imports.","triggerScenarios":"Calling load_tasks / load_tasks_for_async_import / load_tasks_for_async_import_streaming with a tasks list whose len(tasks) > settings.TASKS_MAX_NUMBER (default 100 in Label Studio). Typical via POST to the /api/projects/{id}/import endpoint with a large JSON/CSV file or inline tasks array.","commonSituations":"Bulk-importing a dataset larger than the configured limit; a fresh install keeping the low default TASKS_MAX_NUMBER; a script exporting from another tool and piping tens of thousands of rows straight into one import call; environment variable TASKS_MAX_NUMBER set lower than expected (e.g. set to a small value or a non-numeric that clamps).","solutions":["Raise the limit: set TASKS_MAX_NUMBER (e.g. export TASKS_MAX_NUMBER=1000000) in the Label Studio environment and restart.","Split the import into multiple smaller batches, each under settings.TASKS_MAX_NUMBER tasks.","Use the storage-sync import path (S3/GCS/Azure/Redis) or load_tasks_for_async_import_streaming for very large datasets instead of one-shot import.","If importing via API, check the dataset row count against the server's limit before calling."],"exampleFix":"// before (one-shot import of 50000 tasks)\nrequests.post(url + '/api/projects/1/import', json={'tasks': big_tasks})\n\n// after (batched)\nfor i in range(0, len(big_tasks), 10000):\n    requests.post(url + '/api/projects/1/import', json={'tasks': big_tasks[i:i+10000]})","handlingStrategy":"validation","validationCode":"import os, requests\nMAX = int(os.environ.get('TASKS_MAX_NUMBER', 100))\nif len(tasks) > MAX:\n    raise ValueError(f'{len(tasks)} tasks exceeds limit {MAX}; batch or raise TASKS_MAX_NUMBER')\nrequests.post(api + f'/projects/{pid}/import', json={'tasks': tasks})","typeGuard":null,"tryCatchPattern":"try:\n    import_tasks(tasks)\nexcept ValidationError as e:\n    if 'Maximum task number' in str(e):\n        batch_import(tasks, size=MAX)  # split and retry per batch\n    else:\n        raise","preventionTips":["Check len(tasks) against settings.TASKS_MAX_NUMBER before every import call.","Default to batching imports (e.g. 10k per request) regardless of limit.","Keep TASKS_MAX_NUMBER documented in your deploy config alongside expected dataset sizes.","For very large datasets prefer storage sync or the streaming import path."],"tags":["django","validation","import-limit","label-studio"],"backgroundTag":"max-task-limit-exceeded","analyzedSha":"0b49e9b53917880baf1dd85d574fe5541a9aafb2","analyzedAt":"2026-08-29T00:39:52.578Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}