{"record":{"id":"5a9a5f126d1255a3","repo":"abpframework/abp","slug":"container-name-contains-invalid-characters-conta","errorCode":null,"errorMessage":"Container name contains invalid characters: {containerName}. Only lowercase letters, numbers, and hyphens are allowed.","messagePattern":"Container name contains invalid characters: (.+?)\\. Only lowercase letters, numbers, and hyphens are allowed\\.","errorType":"exception","errorClass":"AbpException","httpStatus":null,"severity":"error","filePath":"framework/src/Volo.Abp.BlobStoring.Bunny/Volo/Abp/BlobStoring/Bunny/BunnyBlobNamingNormalizer.cs","lineNumber":35,"sourceCode":"\n    public virtual string NormalizeContainerName(string containerName)\n    {\n        Check.NotNullOrWhiteSpace(containerName, nameof(containerName));\n\n        using (CultureHelper.Use(CultureInfo.InvariantCulture))\n        {\n            // Trim whitespace and convert to lowercase\n            var normalizedName = containerName\n                .Trim()\n                .ToLowerInvariant();\n\n            // Remove any invalid characters\n            normalizedName = Regex.Replace(normalizedName, \"[^a-z0-9-]\", string.Empty);\n\n            // Validate structure\n            if (!ValidCharactersRegex.IsMatch(normalizedName))\n            {\n                throw new AbpException(\n                    $\"Container name contains invalid characters: {containerName}. \" +\n                    \"Only lowercase letters, numbers, and hyphens are allowed.\");\n            }\n\n            // Validate length\n            if (normalizedName.Length < MinLength || normalizedName.Length > MaxLength)\n            {\n                throw new AbpException(\n                    $\"Container name must be between {MinLength} and {MaxLength} characters. \" +\n                    $\"Current length: {normalizedName.Length}\");\n            }\n\n            return normalizedName;\n        }\n    }\n}\n","sourceCodeStart":17,"sourceCodeEnd":52,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.BlobStoring.Bunny/Volo/Abp/BlobStoring/Bunny/BunnyBlobNamingNormalizer.cs#L17-L52","documentation":"Thrown by BunnyBlobNamingNormalizer.NormalizeContainerName when, after trimming/lowercasing and stripping every character outside [a-z0-9-], the result still fails the ^[a-z0-9-]*$ structural regex. Because the preceding Regex.Replace already removes all disallowed characters, this branch is effectively a defensive structural assertion that the normalized name matches Bunny's allowed alphabet. The original (pre-normalized) containerName is included in the message.","triggerScenarios":"Configuring a Bunny blob container whose name, after normalization, does not satisfy the allowed-character set. In practice this requires the strip step to leave something the regex rejects, which is unreachable given the strip uses the same character class; it functions as a guard against future changes to the normalization pipeline.","commonSituations":"Supplying a container name with only disallowed characters (so normalization yields an edge case), or a container name that the normalizer cannot sanitize into a valid Bunny storage-zone name. Most real invalid input is silently stripped rather than throwing here.","solutions":["Provide a container name composed solely of lowercase letters, digits, and hyphens.","Set an explicit ContainerName in the Bunny configuration that already satisfies the rules.","Validate the container name before it reaches the normalizer."],"exampleFix":"// before\n\"Bunny\": { \"ContainerName\": \"My App_Data\" }\n\n// after\n\"Bunny\": { \"ContainerName\": \"my-app-data\" }","handlingStrategy":"validation","validationCode":"static readonly Regex Valid = new(@\"^[a-z0-9-]+$\");\nif (!Valid.IsMatch(containerName))\n    throw new ArgumentException(\"Container name must be lowercase letters, digits, hyphens only.\");","typeGuard":"static bool IsValidBunnyContainerName(string name) => Regex.IsMatch(name, @\"^[a-z0-9-]+$\");","tryCatchPattern":"try { NormalizeContainerName(name); }\ncatch (AbpException ex) when (ex.Message.Contains(\"invalid characters\"))\n{ /* sanitize or reject the name */ }","preventionTips":["Use only lowercase letters, digits, and hyphens for Bunny container names.","Validate the name at configuration time, not at first blob operation.","Note the normalizer strips invalid chars first, so prefer already-clean names."],"tags":["bunny","validation","container-name","configuration","abp"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}