HumanSignal/label-studio · error · ValidationError

load_tasks: No data found in DATA or in FILES

Error message

load_tasks: No data found in DATA or in FILES

What it means

load_tasks reached the end of its content-type dispatch without finding a supported data source: the request was not multipart file upload, not a urlencoded request with a url, and not an application/json request whose body is a list. It raises this ValidationError indicating no task data could be located in request DATA or FILES.

Source

Thrown at label_studio/data_import/uploader.py:394

            (
                data_keys,
                found_formats,
                tasks,
                file_upload_ids,
                could_be_tasks_list,
            ) = tasks_from_url(file_upload_ids, project, request.user, url, could_be_tasks_list)

    # take one task from request DATA
    elif 'application/json' in request.content_type and isinstance(request.data, dict):
        tasks = [request.data]

    # take many tasks from request DATA
    elif 'application/json' in request.content_type and isinstance(request.data, list):
        tasks = request.data

    # incorrect data source
    else:
        raise ValidationError('load_tasks: No data found in DATA or in FILES')

    # check is data root is list
    if not isinstance(tasks, list):
        raise ValidationError('load_tasks: Data root must be list')

    # empty tasks error
    if not tasks:
        raise ValidationError('load_tasks: No tasks added')

    check_max_task_number(tasks)
    return tasks, file_upload_ids, could_be_tasks_list, found_formats, list(data_keys)

View on GitHub (pinned to 0b49e9b539)

Solutions

  1. Send the tasks as a JSON array with Content-Type: application/json
  2. Or upload files via multipart/form-data, or provide a 'url' form field with urlencoded content type
  3. Verify the Content-Type header matches the actual body format

Example fix

// before
requests.post(import_url, json={"data": [{"text": "x"}]})  # object root
// after
requests.post(import_url, json=[{"data": {"text": "x"}}])  # list root, application/json
Defensive patterns

Strategy: validation

Validate before calling

def validate_import_request(body, content_type):
    if 'application/json' in content_type and not isinstance(body, list):
        raise ValueError('JSON import body must be a list of tasks')
    if not body:
        raise ValueError('Import body is empty')

Type guard

def is_list_body(content_type, body):
    return 'application/json' in content_type and isinstance(body, list)

Try / catch

try:
    import_tasks(body)
except ValidationError as e:
    if 'No data found in DATA or in FILES' in str(e):
        raise UserInputError('Send a JSON array body, multipart files, or urlencoded url')
    raise

Prevention

When it happens

Trigger: Sending the import request with an unsupported Content-Type (e.g. text/plain, application/json with a non-list body such as an object or string), or an empty body.

Common situations: Posting a JSON object instead of a JSON array; missing Content-Type header so Django can't parse data; clients sending XML or plain text; SDK misuse passing a dict to a function that expects a list.

Related errors


AI-assisted analysis of HumanSignal/label-studio@0b49e9b539 (2026-08-29). Data as JSON: /api/errors/416909df9fda5475. Report an issue: GitHub.