HumanSignal/label-studio · error · KeyError
Container not found: {self.container}
Error message
Container not found: {self.container} What it means
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.
Source
Thrown at label_studio/io_storages/azure_blob/models.py:90
+ ';EndpointSuffix=core.windows.net'
)
client = BlobServiceClient.from_connection_string(conn_str=connection_string)
container = client.get_container_client(str(self.container))
return client, container
def get_container(self):
_, container = self.get_client_and_container()
return container
def validate_connection(self, **kwargs):
logger.debug('Validating Azure Blob Storage connection')
client, container = self.get_client_and_container()
try:
container_properties = container.get_container_properties()
logger.debug(f'Container exists: {container_properties.name}')
except ResourceNotFoundError:
raise KeyError(f'Container not found: {self.container}')
# Check path existence for Import storages only
if self.prefix and 'Export' not in self.__class__.__name__:
logger.debug(f'Test connection to container {self.container} with prefix {self.prefix}')
prefix = str(self.prefix)
try:
blob = next(container.list_blob_names(name_starts_with=prefix))
except StopIteration:
blob = None
if not blob:
raise KeyError(f'{self.url_scheme}://{self.container}/{self.prefix} not found.')
def get_bytes_stream(self, uri, range_header=None):
"""Get file bytes from Azure Blob storage as a streaming object with metadata.
Implements range request support similar to GCS and S3 implementations:
- Accepts ``range_header`` in format ``bytes=start-end``View on GitHub (pinned to 0b49e9b539)
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
Example fix
// before
{"container": "Documents"} // actual container is 'documents' → KeyError Container not found
// after
{"container": "documents"} → 200 valid Defensive patterns
Strategy: validation
Validate before calling
from azure.storage.blob import BlobServiceClient
svc = BlobServiceClient(account_url=f"https://{acct}.blob.core.windows.net", credential=key)
existing = {c.name for c in svc.list_containers()}
assert container_name in existing, f"Container '{container_name}' does not exist; have: {existing}" Type guard
def container_exists(svc, name):
return any(c.name == name for c in svc.list_containers()) Try / catch
try:
resp = requests.post(f"{LS_URL}/api/storages/azure/validate/", json=payload, headers=headers)
resp.raise_for_status()
except requests.HTTPError as e:
if "Container not found" in resp.text:
logging.error("Create the container or fix its name (case-sensitive): %s", resp.text) Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- {self.url_scheme}://{self.container}/{self.prefix} not found
- {underlying connection validation error}
- {connection validation error}
- Validation failed on {}: {}
- Label config contains non-unique names:
AI-assisted analysis of HumanSignal/label-studio@0b49e9b539 (2026-08-29).
Data as JSON: /api/errors/658e8bfeb7cee9af.
Report an issue: GitHub.