HumanSignal/label-studio · error · ValidationError

extract_message(e)

Error message

extract_message(e)

What it means

ValidationError raised by tasks_from_url's catch-all handler in label_studio/data_import/uploader.py. Any non-ValidationError exception during URL download/parsing (network failures, HTTP errors, bad JSON, decompression issues) is caught, flattened with extract_message(e), and re-raised as a ValidationError. The original exception type and traceback are lost — the message text is the only diagnostic.

Source

Thrown at label_studio/data_import/uploader.py:170

        if ext and ext.lower() not in settings.SUPPORTED_EXTENSIONS:
            raise ValidationError(f'{ext} extension is not supported')

        # Check file size before downloading
        content_length = response.headers.get('content-length')
        if content_length:
            check_tasks_max_file_size(int(content_length))

        file_content = response.content
        file_upload = create_file_upload(user, project, SimpleUploadedFile(filename, file_content))
        if file_upload.format_could_be_tasks_list:
            could_be_tasks_list = True
        file_upload_ids.append(file_upload.id)
        tasks, found_formats, data_keys = FileUpload.load_tasks_from_uploaded_files(project, file_upload_ids)

    except ValidationError as e:
        raise e
    except Exception as e:
        raise ValidationError(extract_message(e))
    return data_keys, found_formats, tasks, file_upload_ids, could_be_tasks_list


@timeit
def create_file_uploads(user, project, FILES):
    could_be_tasks_list = False
    file_upload_ids = []
    check_request_files_size(FILES)
    check_extensions(FILES)
    for _, file in FILES.items():
        file_upload = create_file_upload(user, project, file)
        if file_upload.format_could_be_tasks_list:
            could_be_tasks_list = True
        file_upload_ids.append(file_upload.id)

    logger.debug(f'created file uploads: {file_upload_ids} could_be_tasks_list: {could_be_tasks_list}')
    return file_upload_ids, could_be_tasks_list

View on GitHub (pinned to 0b49e9b539)

Solutions

  1. Read the raised message: it embeds the underlying error (HTTP status, connection message) and fix that root cause.
  2. Verify the URL is reachable from the server (curl it on the Label Studio host), including auth/expiry for presigned URLs.
  3. Download the file client-side, validate/convert it, and upload directly instead of passing a URL.
  4. Increase timeouts / configure proxy env vars (HTTP_PROXY/HTTPS_PROXY) on the server if network egress is restricted.

Example fix

// before
url = 'https://internal.example.com/data.json' // 404 -> wrapped ValidationError

// after
downloadAndValidate(url); // fail fast client-side with real error
uploadFile(convertedJson);
Defensive patterns

Strategy: try-catch

Validate before calling

import requests
resp = requests.head(url, allow_redirects=True, timeout=10)
resp.raise_for_status()
cl = resp.headers.get('content-length')
if cl and int(cl) >= TASKS_MAX_FILE_SIZE:
    raise ValueError('file too large for import')

Try / catch

try:
    import_from_url(url)
except ValidationError as e:
    msg = str(e)
    if 'Max retries' in msg or 'timed out' in msg or 'Connection' in msg:
        check_network_or_proxy(url); retry_with_backoff()
    elif 'HTTPError' in msg or '404' in msg or '403' in msg:
        fix_url_or_credentials(url)
    else:
        raise

Prevention

When it happens

Trigger: tasks_from_url receiving a URL that fails to download (ConnectionError, Timeout, HTTPError from response.raise_for_status), a content-length that fails size check inside parsing, or load_tasks_from_uploaded_files choking on malformed content; all wrapped into ValidationError(extract_message(e)).

Common situations: Dead or unreachable URLs; presigned URLs expired (403); huge files timing out mid-download; URLs returning HTML error pages instead of data; proxy/firewall blocking outbound requests from the server.

Related errors


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