abpframework/abp · error · Exception
Invalid directory path generated from blob name.
Error message
Invalid directory path generated from blob name.
What it means
Thrown by BunnyBlobProvider.BlobExistsAsync when the computed directoryPath (derived from Path.GetDirectoryName of the full blob path, with backslashes converted to forward slashes, plus a trailing '/') is null or whitespace. It guards against producing an invalid directory listing request to Bunny. The full path is built as '/{containerName}/{blobName}'.
Source
Thrown at framework/src/Volo.Abp.BlobStoring.Bunny/Volo/Abp/BlobStoring/Bunny/BunnyBlobProvider.cs:111
{
return await bunnyStorage.DownloadObjectAsStreamAsync($"{containerName}/{blobName}");
}
catch (WebException ex) when ((HttpStatusCode)ex.Status == HttpStatusCode.NotFound)
{
return null;
}
}
protected virtual async Task<bool> BlobExistsAsync(BunnyCDNStorage bunnyStorage, string containerName, string blobName)
{
try
{
var fullBlobPath = $"/{containerName}/{blobName}";
var directoryPath = Path.GetDirectoryName(fullBlobPath)?.Replace('\\', '/') + "/";
if (string.IsNullOrWhiteSpace(directoryPath))
{
throw new Exception("Invalid directory path generated from blob name.");
}
var objects = await bunnyStorage.GetStorageObjectsAsync(directoryPath);
return objects?.Any(o => o.FullPath == fullBlobPath) == true;
}
catch (BunnyCDNStorageException ex) when (ex.Message.Contains("404"))
{
return false;
}
catch (Exception ex)
{
throw new Exception($"Error while checking blob existence: {ex.Message}", ex);
}
}
protected virtual async Task<BunnyCDNStorage> GetBunnyCDNStorageAsync(BlobProviderArgs args)
{
var configuration = args.Configuration.GetBunnyConfiguration();View on GitHub (pinned to 7ed43b1931)
Solutions
- Ensure the blob name is non-empty and contains a meaningful file name component.
- Validate that the container name is set and non-whitespace before any operation.
- Avoid blob names that consist solely of path separators or that resolve to a root path.
Example fix
// before
await container.SaveAsync("", stream);
// after
if (string.IsNullOrWhiteSpace(blobName))
throw new ArgumentException("Blob name required.", nameof(blobName));
await container.SaveAsync(blobName, stream); Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrWhiteSpace(blobName))
throw new ArgumentException("Blob name must be non-empty.", nameof(blobName));
await container.SaveAsync(blobName, stream); Type guard
static bool IsValidBlobName(string name) => !string.IsNullOrWhiteSpace(name) && !name.All(c => c == '/' || c == '\\');
Try / catch
try { await container.ExistsAsync(blobName); }
catch (Exception ex) when (ex.Message.Contains("Invalid directory path"))
{ /* supply a valid blob name */ } Prevention
- Always pass a non-empty, meaningful blob name.
- Avoid names consisting solely of path separators.
- Validate blob names at the application boundary.
When it happens
Trigger: The existence check computes directoryPath and it comes back empty/whitespace, which can occur with malformed or empty blob/container names that cause Path.GetDirectoryName to return an unexpected value. Triggered on Save/Delete/Exists/Get when the path cannot be resolved into a directory.
Common situations: An empty or whitespace blob name, a container/blob combination that yields a degenerate path, or platform-specific Path.GetDirectoryName behavior with leading-slash inputs that returns an empty result.
Related errors
- Container name contains invalid characters: {containerName}.
- Container name must be between {MinLength} and {MaxLength} c
- Blob '{args.BlobName}' already exists in container '{contain
- Error while checking blob existence: {ex.Message}
- Given tenant doesn't exist: {0}
AI-assisted analysis of abpframework/abp@7ed43b1931 (2026-08-13).
Data as JSON: /api/errors/cae93b721510f1d2.
Report an issue: GitHub.