{"record":{"id":"41fb409bb49b13f2","repo":"dotnet/orleans","slug":"invalid-container-name","errorCode":null,"errorMessage":"Invalid container name","messagePattern":"Invalid container name","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Azure/Shared/Storage/AzureBlobUtils.cs","lineNumber":25,"sourceCode":"#elif ORLEANS_STREAMING\nnamespace Orleans.Streaming.AzureStorage\n#else\n// No default namespace intentionally to cause compile errors if something is not defined\n#endif\n{\n    /// <summary>\n    /// General utility functions related to Azure Blob storage.\n    /// </summary>\n    internal static partial class AzureBlobUtils\n    {\n        [GeneratedRegex(\"^[a-z0-9]+(-[a-z0-9]+)*$\", RegexOptions.ExplicitCapture | RegexOptions.Singleline | RegexOptions.CultureInvariant)]\n        private static partial Regex ContainerNameRegex();\n\n        internal static void ValidateContainerName(string containerName)\n        {\n            if (string.IsNullOrWhiteSpace(containerName) || containerName.Length < 3 || containerName.Length > 63 || !ContainerNameRegex().IsMatch(containerName))\n            {\n                throw new ArgumentException(\"Invalid container name\", nameof(containerName));\n            }\n        }\n\n        internal static void ValidateBlobName(string blobName)\n        {\n            if (string.IsNullOrWhiteSpace(blobName) || blobName.Length > 1024 || blobName.Count(c => c == '/') >= 254)\n            {\n                throw new ArgumentException(\"Invalid blob name\", nameof(blobName));\n            }\n        }\n    }\n}\n","sourceCodeStart":7,"sourceCodeEnd":38,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/Azure/Shared/Storage/AzureBlobUtils.cs#L7-L38","documentation":"Thrown by AzureBlobUtils.ValidateContainerName when the container name is blank, shorter than 3, longer than 63 characters, or does not match the pattern ^[a-z0-9]+(-[a-z0-9]+)*$ (lowercase alphanumeric with single dashes between groups). These are Azure Blob storage naming rules enforced client-side.","triggerScenarios":"Supplying a container name that violates Azure naming rules: uppercase letters, underscores, leading/trailing/consecutive dashes, wrong length, or whitespace.","commonSituations":"Using an environment/project name with uppercase or underscores as the container; a computed name that is too short or empty; trailing dash from string trimming.","solutions":["Normalize the name to lowercase alphanumeric with single internal dashes (e.g. \"orleans-grain-state\").","Ensure length is between 3 and 63 characters.","Replace invalid characters (underscores -> dashes) and collapse consecutive/trailing dashes.","Validate the name against the regex before passing it in."],"exampleFix":"// before\nvar container = \"Orleans_GrainState\"; // uppercase + underscore -> invalid\n\n// after\nvar container = \"orleans-grain-state\";","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(containerName) || containerName.Length < 3 || containerName.Length > 63\n    || !Regex.IsMatch(containerName, @\"^[a-z0-9]+(-[a-z0-9]+)*$\"))\n    throw new ArgumentException(\"Invalid container name\");","typeGuard":"static bool IsValidContainerName(string? n) =>\n    !string.IsNullOrWhiteSpace(n) && n.Length is >= 3 and <= 63\n    && Regex.IsMatch(n, @\"^[a-z0-9]+(-[a-z0-9]+)*$\");","tryCatchPattern":null,"preventionTips":["Normalize container names to lowercase alphanumeric with single internal dashes.","Generate container names from a known-safe alphabet only."],"tags":["azure-blob","validation","naming","azure","configuration"],"backgroundTag":null,"analyzedSha":"fca799fa70ecb6ad975224271703ca43221f58de","analyzedAt":"2026-08-13T19:55:57.938Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}