{"record":{"id":"6b2e8cd66b0e89b1","repo":"microsoft/graphrag","slug":"container-name-must-be-between-3-and-63-characters","errorCode":null,"errorMessage":"Container name must be between 3 and 63 characters long and contain only lowercase letters, numbers, or hyphens. Name provided was {container_name}.","messagePattern":"Container name must be between 3 and 63 characters long and contain only lowercase letters, numbers, or hyphens\\. Name provided was (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/graphrag-storage/graphrag_storage/azure_blob_storage.py","lineNumber":278,"sourceCode":"        - Start with a letter or number\n        - All letters used in blob container names must be lowercase.\n        - Contain only letters, numbers, or the hyphen.\n        - Consecutive hyphens are not permitted.\n        - Cannot end with a hyphen.\n\n    Args:\n    -----\n    container_name (str)\n        The blob container name to be validated.\n\n    Returns\n    -------\n        bool: True if valid, False otherwise.\n    \"\"\"\n    # Match alphanumeric or single hyphen not at the start or end, repeated 3-63 times.\n    if not re.match(r\"^(?:[0-9a-z]|(?<!^)-(?!$)){3,63}$\", container_name):\n        msg = f\"Container name must be between 3 and 63 characters long and contain only lowercase letters, numbers, or hyphens. Name provided was {container_name}.\"\n        raise ValueError(msg)\n","sourceCodeStart":260,"sourceCodeEnd":279,"githubUrl":"https://github.com/microsoft/graphrag/blob/f40e9a26ce62ba0b3fef8837d24aafdcc6e6c704/packages/graphrag-storage/graphrag_storage/azure_blob_storage.py#L260-L279","documentation":"AzureBlobStorage validates container names against Azure's rules: 3-63 characters, only lowercase letters, digits, and hyphens that are not leading/trailing (no consecutive-hyphen-friendly guarantees beyond the regex). A name failing the regex raises ValueError before the client is created.","triggerScenarios":"Passing container_name with uppercase letters, underscores, dots, a leading/trailing hyphen, or fewer than 3 / more than 63 characters to AzureBlobStorage.__init__.","commonSituations":"Deriving container names from user input, dataset names, or project slugs containing '_' or capitals (common on GitHub repos), or a base_dir/container split that accidentally includes a slash.","solutions":["Normalize the name: lowercase, replace '_'/'.'/'/' with '-', strip leading/trailing hyphens, truncate to 63 chars","Validate names at config load time with the same regex before constructing storage","For names that can't be sanitized losslessly, maintain an explicit mapping table","Add a unit check if container names come from external input"],"exampleFix":"# before\nstorage = AzureBlobStorage(container_name='My_Project.Cache')  # ValueError\n\n# after\nimport re\nname = re.sub(r'[^a-z0-9-]', '-', 'My_Project.Cache'.lower()).strip('-')[:63]\nstorage = AzureBlobStorage(container_name=name)","handlingStrategy":"validation","validationCode":"import re\nCONTAINER_RE = re.compile(r'^(?:[0-9a-z]|(?<!^)-(?!$)){3,63}$')\ndef valid_container_name(name: str) -> bool:\n    return bool(CONTAINER_RE.match(name))\nassert valid_container_name(container_name)","typeGuard":"import re\ndef is_valid_container_name(name: str) -> bool:\n    return bool(re.match(r'^(?:[0-9a-z]|(?<!^)-(?!$)){3,63}$', name))","tryCatchPattern":"try:\n    s = AzureBlobStorage(container_name=name, ...)\nexcept ValueError as e:\n    if 'Container name' in str(e):\n        name = re.sub(r'[^a-z0-9-]', '-', name.lower()).strip('-')[:63]\n        s = AzureBlobStorage(container_name=name, ...)\n    else:\n        raise","preventionTips":["Sanitize any derived container name at config load time","Add the same regex check in CI for config values coming from user input"],"tags":["azure","blob-storage","validation","naming"],"backgroundTag":"invalid-azure-container-name","analyzedSha":"f40e9a26ce62ba0b3fef8837d24aafdcc6e6c704","analyzedAt":"2026-08-27T11:16:29.677Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}