HumanSignal/label-studio · error · ValidationError

Error validating storage connection

Error message

Error validating storage connection

What it means

After serializer validation, validate_storage_instance explicitly calls instance.validate_connection() as a double-check (not all storage serializers validate in the serializer) and wraps ANY exception in a generic ValidationError('Error validating storage connection'). The original cause is only in the server log via logger.error.

Source

Thrown at label_studio/io_storages/functions.py:64

            raise PermissionDenied()

    # combine instance fields with request.data
    serializer = serializer_class(data=request.data)
    serializer.is_valid(raise_exception=True)

    # if storage exists, we have to use instance from DB,
    # because instance from serializer won't have credentials, they were popped intentionally
    if instance:
        instance = serializer.update(instance, serializer.validated_data)
    else:
        instance = serializer_class.Meta.model(**serializer.validated_data)

    # double check: not all storages validate connection in serializer, just make another explicit check here
    try:
        instance.validate_connection()
    except Exception as exc:
        logger.error(f'Error validating storage connection: {exc}')
        raise ValidationError('Error validating storage connection')

    return instance


def get_storage_list():
    return [
        {
            'name': 's3',
            'title': 'AWS S3',
            'import_list_api': S3ImportStorageListAPI,
            'export_list_api': S3ExportStorageListAPI,
        },
        {
            'name': 'gcs',
            'title': 'Google Cloud Storage',
            'import_list_api': GCSImportStorageListAPI,
            'export_list_api': GCSExportStorageListAPI,
        },

View on GitHub (pinned to 0b49e9b539)

Solutions

  1. Check the server log line 'Error validating storage connection: {exc}' for the underlying exception and fix that root cause
  2. Verify credentials and resource names in storage settings; click 'Validate and Import' to re-test
  3. From the server host, test connectivity to the provider (e.g. aws s3 ls s3://bucket) — proxies/firewalls often differ from your laptop
  4. For GCS specifically, confirm the credentials JSON parses and the service account has Storage Object Viewer/Creator roles
  5. If the serializer for your storage type already validates connections, remove duplicate/incorrect connection params

Example fix

// before
{"bucket": "my-bukket", "aws_access_key_id": "AKIA...", "aws_secret_access_key": "old"}
// after
{"bucket": "my-bucket", "aws_access_key_id": "AKIA...", "aws_secret_access_key": "<rotated-key>"}  // validated via aws s3 ls
Defensive patterns

Strategy: validation

Validate before calling

def storage_connection_ok(storage):
    try:
        storage.validate_connection()
        return True, None
    except Exception as e:
        return False, str(e)

Try / catch

from rest_framework.exceptions import ValidationError
try:
    resp = api_create_storage(payload)
except ValidationError as e:
    if 'Error validating storage connection' in str(e.detail):
        logger.error('Connection check failed — check server log for root cause and credentials/bucket settings')

Prevention

When it happens

Trigger: Creating/updating any storage whose connection check fails: bad bucket name, wrong region/endpoint, invalid or expired cloud credentials, network/firewall blocking the cloud API, or nonexistent container/prefix.

Common situations: Typo'd bucket or container names; AWS keys without s3:Get/List permission; Azure account keys rotated; GCP service account JSON invalid (see related GCS error); corporate proxy blocking outbound HTTPS to the storage API.

Related errors


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