{"record":{"id":"6aec6c656bb87287","repo":"HumanSignal/label-studio","slug":"error-validating-storage-connection","errorCode":null,"errorMessage":"Error validating storage connection","messagePattern":"Error validating storage connection","errorType":"validation","errorClass":"ValidationError","httpStatus":400,"severity":"error","filePath":"label_studio/io_storages/functions.py","lineNumber":64,"sourceCode":"            raise PermissionDenied()\n\n    # combine instance fields with request.data\n    serializer = serializer_class(data=request.data)\n    serializer.is_valid(raise_exception=True)\n\n    # if storage exists, we have to use instance from DB,\n    # because instance from serializer won't have credentials, they were popped intentionally\n    if instance:\n        instance = serializer.update(instance, serializer.validated_data)\n    else:\n        instance = serializer_class.Meta.model(**serializer.validated_data)\n\n    # double check: not all storages validate connection in serializer, just make another explicit check here\n    try:\n        instance.validate_connection()\n    except Exception as exc:\n        logger.error(f'Error validating storage connection: {exc}')\n        raise ValidationError('Error validating storage connection')\n\n    return instance\n\n\ndef get_storage_list():\n    return [\n        {\n            'name': 's3',\n            'title': 'AWS S3',\n            'import_list_api': S3ImportStorageListAPI,\n            'export_list_api': S3ExportStorageListAPI,\n        },\n        {\n            'name': 'gcs',\n            'title': 'Google Cloud Storage',\n            'import_list_api': GCSImportStorageListAPI,\n            'export_list_api': GCSExportStorageListAPI,\n        },","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/HumanSignal/label-studio/blob/0b49e9b53917880baf1dd85d574fe5541a9aafb2/label_studio/io_storages/functions.py#L46-L82","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the server log line 'Error validating storage connection: {exc}' for the underlying exception and fix that root cause","Verify credentials and resource names in storage settings; click 'Validate and Import' to re-test","From the server host, test connectivity to the provider (e.g. aws s3 ls s3://bucket) — proxies/firewalls often differ from your laptop","For GCS specifically, confirm the credentials JSON parses and the service account has Storage Object Viewer/Creator roles","If the serializer for your storage type already validates connections, remove duplicate/incorrect connection params"],"exampleFix":"// before\n{\"bucket\": \"my-bukket\", \"aws_access_key_id\": \"AKIA...\", \"aws_secret_access_key\": \"old\"}\n// after\n{\"bucket\": \"my-bucket\", \"aws_access_key_id\": \"AKIA...\", \"aws_secret_access_key\": \"<rotated-key>\"}  // validated via aws s3 ls","handlingStrategy":"validation","validationCode":"def storage_connection_ok(storage):\n    try:\n        storage.validate_connection()\n        return True, None\n    except Exception as e:\n        return False, str(e)","typeGuard":null,"tryCatchPattern":"from rest_framework.exceptions import ValidationError\ntry:\n    resp = api_create_storage(payload)\nexcept ValidationError as e:\n    if 'Error validating storage connection' in str(e.detail):\n        logger.error('Connection check failed — check server log for root cause and credentials/bucket settings')","preventionTips":["Check the server log for the underlying exception (logger.error includes exc)","Verify bucket/container names and cloud credentials before saving","Test connectivity from the server host, not your laptop (proxies/firewalls)","Grant least-privilege IAM roles (List/Get/Put for the target prefix)"],"tags":["storage","cloud","validation","connectivity"],"backgroundTag":"storage-connection-validation-failed","analyzedSha":"0b49e9b53917880baf1dd85d574fe5541a9aafb2","analyzedAt":"2026-08-29T00:39:52.578Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}