{"record":{"id":"658e8bfeb7cee9af","repo":"HumanSignal/label-studio","slug":"container-not-found-self-container","errorCode":null,"errorMessage":"Container not found: {self.container}","messagePattern":"Container not found: (.+?)","errorType":"exception","errorClass":"KeyError","httpStatus":null,"severity":"error","filePath":"label_studio/io_storages/azure_blob/models.py","lineNumber":90,"sourceCode":"            + ';EndpointSuffix=core.windows.net'\n        )\n        client = BlobServiceClient.from_connection_string(conn_str=connection_string)\n        container = client.get_container_client(str(self.container))\n        return client, container\n\n    def get_container(self):\n        _, container = self.get_client_and_container()\n        return container\n\n    def validate_connection(self, **kwargs):\n        logger.debug('Validating Azure Blob Storage connection')\n        client, container = self.get_client_and_container()\n\n        try:\n            container_properties = container.get_container_properties()\n            logger.debug(f'Container exists: {container_properties.name}')\n        except ResourceNotFoundError:\n            raise KeyError(f'Container not found: {self.container}')\n\n        # Check path existence for Import storages only\n        if self.prefix and 'Export' not in self.__class__.__name__:\n            logger.debug(f'Test connection to container {self.container} with prefix {self.prefix}')\n            prefix = str(self.prefix)\n            try:\n                blob = next(container.list_blob_names(name_starts_with=prefix))\n            except StopIteration:\n                blob = None\n\n            if not blob:\n                raise KeyError(f'{self.url_scheme}://{self.container}/{self.prefix} not found.')\n\n    def get_bytes_stream(self, uri, range_header=None):\n        \"\"\"Get file bytes from Azure Blob storage as a streaming object with metadata.\n\n        Implements range request support similar to GCS and S3 implementations:\n        - Accepts ``range_header`` in format ``bytes=start-end``","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/HumanSignal/label-studio/blob/0b49e9b53917880baf1dd85d574fe5541a9aafb2/label_studio/io_storages/azure_blob/models.py#L72-L108","documentation":"During Azure Blob connection validation, the SDK raises ResourceNotFoundError when the target container cannot be found, which the code translates to KeyError('Container not found: {name}'). This means credentials/auth succeeded but the named container does not exist (or is inaccessible) in the account.","triggerScenarios":"POST /api/storages/azure/validate or creating a storage where 'container' names a container that does not exist in the account, or the account key lacks rights to read container properties.","commonSituations":"Typo in container name or case mismatch; container created in a different storage account than the configured one; container deleted after being configured; restricted IAM denying get_container_properties.","solutions":["Run 'az storage container list --account-name <acct>' and use an exact existing container name","Create the container if it should exist: az storage container create --name <name>","Verify account_name/key refer to the correct storage account (case-sensitive container names)","Check access key / SAS permissions allow reading container metadata"],"exampleFix":"// before\n{\"container\": \"Documents\"}  // actual container is 'documents' → KeyError Container not found\n// after\n{\"container\": \"documents\"}  → 200 valid","handlingStrategy":"validation","validationCode":"from azure.storage.blob import BlobServiceClient\nsvc = BlobServiceClient(account_url=f\"https://{acct}.blob.core.windows.net\", credential=key)\nexisting = {c.name for c in svc.list_containers()}\nassert container_name in existing, f\"Container '{container_name}' does not exist; have: {existing}\"","typeGuard":"def container_exists(svc, name):\n    return any(c.name == name for c in svc.list_containers())","tryCatchPattern":"try:\n    resp = requests.post(f\"{LS_URL}/api/storages/azure/validate/\", json=payload, headers=headers)\n    resp.raise_for_status()\nexcept requests.HTTPError as e:\n    if \"Container not found\" in resp.text:\n        logging.error(\"Create the container or fix its name (case-sensitive): %s\", resp.text)","preventionTips":["List containers with `az storage container list` and copy exact names","Container names are case-sensitive — match exactly","Create the container before configuring the storage","Confirm the storage account in the config is the one holding the container"],"tags":["azure","cloud-storage","not-found","validation","container"],"backgroundTag":"container-not-found","analyzedSha":"0b49e9b53917880baf1dd85d574fe5541a9aafb2","analyzedAt":"2026-08-29T00:39:52.578Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}