{"record":{"id":"cae93b721510f1d2","repo":"abpframework/abp","slug":"invalid-directory-path-generated-from-blob-name","errorCode":null,"errorMessage":"Invalid directory path generated from blob name.","messagePattern":"Invalid directory path generated from blob name\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"framework/src/Volo.Abp.BlobStoring.Bunny/Volo/Abp/BlobStoring/Bunny/BunnyBlobProvider.cs","lineNumber":111,"sourceCode":"        {\n            return await bunnyStorage.DownloadObjectAsStreamAsync($\"{containerName}/{blobName}\");\n        }\n        catch (WebException ex) when ((HttpStatusCode)ex.Status == HttpStatusCode.NotFound)\n        {\n            return null;\n        }\n    }\n\n    protected virtual async Task<bool> BlobExistsAsync(BunnyCDNStorage bunnyStorage, string containerName, string blobName)\n    {\n        try\n        {\n            var fullBlobPath = $\"/{containerName}/{blobName}\";\n            var directoryPath = Path.GetDirectoryName(fullBlobPath)?.Replace('\\\\', '/') + \"/\";\n\n            if (string.IsNullOrWhiteSpace(directoryPath))\n            {\n                throw new Exception(\"Invalid directory path generated from blob name.\");\n            }\n\n            var objects = await bunnyStorage.GetStorageObjectsAsync(directoryPath);\n            return objects?.Any(o => o.FullPath == fullBlobPath) == true;\n        }\n        catch (BunnyCDNStorageException ex) when (ex.Message.Contains(\"404\"))\n        {\n            return false;\n        }\n        catch (Exception ex)\n        {\n            throw new Exception($\"Error while checking blob existence: {ex.Message}\", ex);\n        }\n    }\n\n    protected virtual async Task<BunnyCDNStorage> GetBunnyCDNStorageAsync(BlobProviderArgs args)\n    {\n        var configuration = args.Configuration.GetBunnyConfiguration();","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.BlobStoring.Bunny/Volo/Abp/BlobStoring/Bunny/BunnyBlobProvider.cs#L93-L129","documentation":"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}'.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nawait container.SaveAsync(\"\", stream);\n\n// after\nif (string.IsNullOrWhiteSpace(blobName))\n    throw new ArgumentException(\"Blob name required.\", nameof(blobName));\nawait container.SaveAsync(blobName, stream);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(blobName))\n    throw new ArgumentException(\"Blob name must be non-empty.\", nameof(blobName));\nawait container.SaveAsync(blobName, stream);","typeGuard":"static bool IsValidBlobName(string name) => !string.IsNullOrWhiteSpace(name) && !name.All(c => c == '/' || c == '\\\\');","tryCatchPattern":"try { await container.ExistsAsync(blobName); }\ncatch (Exception ex) when (ex.Message.Contains(\"Invalid directory path\"))\n{ /* supply a valid blob name */ }","preventionTips":["Always pass a non-empty, meaningful blob name.","Avoid names consisting solely of path separators.","Validate blob names at the application boundary."],"tags":["bunny","blob-storage","path","validation","abp"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}