{"record":{"id":"91297ac484f205f5","repo":"HumanSignal/label-studio","slug":"connection-validation-error","errorCode":null,"errorMessage":"{connection validation error}","messagePattern":"\\{connection validation error\\}","errorType":"validation","errorClass":"ValidationError","httpStatus":400,"severity":"error","filePath":"label_studio/io_storages/azure_blob/serializers.py","lineNumber":40,"sourceCode":"            result.pop(attr)\n        return result\n\n    def validate(self, data):\n        data = super(AzureBlobImportStorageSerializer, self).validate(data)\n        storage = self.instance\n        if storage:\n            for key, value in data.items():\n                setattr(storage, key, value)\n        else:\n            if 'id' in self.initial_data:\n                storage_object = self.Meta.model.objects.get(id=self.initial_data['id'])\n                for attr in AzureBlobImportStorageSerializer.secure_fields:\n                    data[attr] = data.get(attr) or getattr(storage_object, attr)\n            storage = self.Meta.model(**data)\n        try:\n            storage.validate_connection()\n        except Exception as exc:\n            raise ValidationError(extract_message(exc))\n        return data\n\n\nclass AzureBlobExportStorageSerializer(ExportStorageSerializer):\n    type = StorageTypeField(default='azure')\n\n    def to_representation(self, instance):\n        result = super().to_representation(instance)\n        result.pop('account_name')\n        result.pop('account_key')\n        return result\n\n    class Meta:\n        model = AzureBlobExportStorage\n        fields = '__all__'\n","sourceCodeStart":22,"sourceCodeEnd":56,"githubUrl":"https://github.com/HumanSignal/label-studio/blob/0b49e9b53917880baf1dd85d574fe5541a9aafb2/label_studio/io_storages/azure_blob/serializers.py#L22-L56","documentation":"AzureBlobImportStorageSerializer.validate runs storage.validate_connection() with the request credentials and converts any exception into a DRF ValidationError whose message is extracted via extract_message(exc). This surfaces raw Azure SDK/credential errors (auth failures, missing container, empty prefix) as a 400 at serializer validation time.","triggerScenarios":"POST/PUT of an Azure Blob import storage where validate_connection throws — wrong account key (AuthenticationFailed), missing credentials, nonexistent container, or empty prefix — triggering the serializer's explicit connection check.","commonSituations":"Account key with whitespace/newline from copy-paste; storage being edited where secure (masked) fields are merged from the existing object but the original credentials were already invalid; container renamed; enterprise firewall blocking blob endpoint.","solutions":["Read the response detail — extract_message surfaces the concrete Azure error","Test credentials with 'az storage blob list' before configuring","Re-enter account_name/account_key cleanly (no stray whitespace) or set the env vars","Fix container/prefix per errors 127/128 guidance","Ensure network access to <account>.blob.core.windows.net"],"exampleFix":"// before\n{\"account_key\": \"<key-with-trailing-newline>\", \"container\": \"docs\"}  → 400 AuthenticationFailed\n// after\n{\"account_key\": \"<clean-key>\", \"container\": \"docs\"}  → 201","handlingStrategy":"validation","validationCode":"# dry-run the credentials with the Azure SDK before POSTing the storage\nfrom azure.storage.blob import BlobServiceClient\nsvc = BlobServiceClient(account_url=f\"https://{account_name}.blob.core.windows.net\", credential=account_key.strip())\nlist(svc.get_container_client(container).list_blob_names(name_starts_with=prefix or \"\"))[:1]","typeGuard":"def azure_import_payload_ok(p):\n    return bool(p.get(\"account_name\") and p.get(\"account_key\") and p.get(\"container\"))","tryCatchPattern":"try:\n    resp = requests.post(f\"{LS_URL}/api/storages/azure/\", json=payload, headers=headers)\n    resp.raise_for_status()\nexcept requests.HTTPError as e:\n    detail = resp.json().get(\"detail\", \"\")  # extracted Azure error message\n    logging.error(\"Azure storage validation failed: %s\", detail)","preventionTips":["Strip whitespace/newlines from pasted account keys","Pre-validate with the Azure SDK/CLI before configuring","Keep env-var credentials in sync with rotated keys","Ensure the host can reach <account>.blob.core.windows.net"],"tags":["azure","cloud-storage","validation","credentials","serializer"],"backgroundTag":"storage-connection-validation-failed","analyzedSha":"0b49e9b53917880baf1dd85d574fe5541a9aafb2","analyzedAt":"2026-08-29T00:39:52.578Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}