abpframework/abp · error · AbpException

Container name contains invalid characters: {containerName}.

Error message

Container name contains invalid characters: {containerName}. Only lowercase letters, numbers, and hyphens are allowed.

What it means

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.

Source

Thrown at framework/src/Volo.Abp.BlobStoring.Bunny/Volo/Abp/BlobStoring/Bunny/BunnyBlobNamingNormalizer.cs:35

    public virtual string NormalizeContainerName(string containerName)
    {
        Check.NotNullOrWhiteSpace(containerName, nameof(containerName));

        using (CultureHelper.Use(CultureInfo.InvariantCulture))
        {
            // Trim whitespace and convert to lowercase
            var normalizedName = containerName
                .Trim()
                .ToLowerInvariant();

            // Remove any invalid characters
            normalizedName = Regex.Replace(normalizedName, "[^a-z0-9-]", string.Empty);

            // Validate structure
            if (!ValidCharactersRegex.IsMatch(normalizedName))
            {
                throw new AbpException(
                    $"Container name contains invalid characters: {containerName}. " +
                    "Only lowercase letters, numbers, and hyphens are allowed.");
            }

            // Validate length
            if (normalizedName.Length < MinLength || normalizedName.Length > MaxLength)
            {
                throw new AbpException(
                    $"Container name must be between {MinLength} and {MaxLength} characters. " +
                    $"Current length: {normalizedName.Length}");
            }

            return normalizedName;
        }
    }
}

View on GitHub (pinned to 7ed43b1931)

Solutions

  1. Provide a container name composed solely of lowercase letters, digits, and hyphens.
  2. Set an explicit ContainerName in the Bunny configuration that already satisfies the rules.
  3. Validate the container name before it reaches the normalizer.

Example fix

// before
"Bunny": { "ContainerName": "My App_Data" }

// after
"Bunny": { "ContainerName": "my-app-data" }
Defensive patterns

Strategy: validation

Validate before calling

static readonly Regex Valid = new(@"^[a-z0-9-]+$");
if (!Valid.IsMatch(containerName))
    throw new ArgumentException("Container name must be lowercase letters, digits, hyphens only.");

Type guard

static bool IsValidBunnyContainerName(string name) => Regex.IsMatch(name, @"^[a-z0-9-]+$");

Try / catch

try { NormalizeContainerName(name); }
catch (AbpException ex) when (ex.Message.Contains("invalid characters"))
{ /* sanitize or reject the name */ }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Related errors


AI-assisted analysis of abpframework/abp@7ed43b1931 (2026-08-13). Data as JSON: /api/errors/5a9a5f126d1255a3. Report an issue: GitHub.