{"record":{"id":"e03959ed279820f8","repo":"OrchardCMS/OrchardCore","slug":"cannot-get-directory-info-with-path-path","errorCode":null,"errorMessage":"Cannot get directory info with path '{path}'.","messagePattern":"Cannot get directory info with path '(.+?)'\\.","errorType":"exception","errorClass":"FileStoreException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.FileStorage.AzureBlob/BlobFileStore.cs","lineNumber":228,"sourceCode":"                }\n\n                var prefix = this.Combine(_basePrefix, path);\n                var directoryClient = _dataLakeFileSystemClient.GetDirectoryClient(prefix);\n\n                if (await directoryClient.ExistsAsync())\n                {\n                    return new BlobDirectory(path, _clock.UtcNow);\n                }\n\n                return null;\n            }\n            catch (RequestFailedException ex) when (ex.Status == 404)\n            {\n                return null;\n            }\n            catch (Exception ex)\n            {\n                throw new FileStoreException($\"Cannot get directory info with path '{path}'.\", ex);\n            }\n        }\n\n        try\n        {\n            if (path == string.Empty)\n            {\n                return new BlobDirectory(path, _clock.UtcNow);\n            }\n\n            var blobDirectory = await GetBlobDirectoryReference(path);\n\n            if (blobDirectory != null)\n            {\n                return new BlobDirectory(path, _clock.UtcNow);\n            }\n\n            return null;","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.FileStorage.AzureBlob/BlobFileStore.cs#L210-L246","documentation":"In BlobFileStore.GetDirectoryInfoAsync, the blob-client path wraps non-404 exceptions in a FileStoreException with this message; a 404 (RequestFailedException with Status==404) is deliberately treated as 'directory does not exist' and returns null. So this error signals an unexpected failure — not a simple missing directory — while resolving the blob 'directory' for the given path.","triggerScenarios":"Calling GetDirectoryInfoAsync(path) where the underlying blob/directory query throws a non-404 exception: invalid characters in path yielding an invalid blob prefix, network/auth failure, container gone, or unexpected service error.","commonSituations":"Paths containing backslashes or reserved characters; misconfigured container name; credential rotation mid-flight; transient Azure outages; passing a file path where callers assumed directory semantics plus a coincidental service failure.","solutions":["Read the inner exception for the true cause (403 auth vs 503 throttling vs invalid name).","Sanitize/validate the path (no '\\\\', no reserved characters) before calling GetDirectoryInfoAsync.","Verify the container and storage credentials are correct and the account is reachable.","Handle a null return as 'not found' instead of probing with malformed paths that can throw."],"exampleFix":"// before\nvar dir = await fileStore.GetDirectoryInfoAsync(folderName.Replace('/', '\\\\'));\n// after\nvar normalized = folderName.Replace('\\\\', '/').Trim('/');\nvar dir = await fileStore.GetDirectoryInfoAsync(normalized);\nif (dir == null) { /* directory does not exist */ }","handlingStrategy":"validation","validationCode":"var normalized = (path ?? string.Empty).Replace('\\\\', '/').Trim('/');\nif (normalized.Split('/', StringSplitOptions.RemoveEmptyEntries).Any(string.IsNullOrWhiteSpace))\n{\n    return null; // invalid directory path\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    var dir = await fileStore.GetDirectoryInfoAsync(normalized);\n    if (dir == null) { /* not found — normal case */ }\n}\ncatch (FileStoreException ex)\n{\n    logger.LogError(ex.InnerException, \"Directory lookup failed for {Path}\", normalized);\n}","preventionTips":["Normalize paths before every BlobFileStore call.","Distinguish 404-as-null from real failures by checking InnerException status codes.","Keep container names and credentials validated at startup.","Wrap repeated lookups in a resilience policy (Polly-style retry)."],"tags":["azure","blob-storage","file-storage","directory-not-found","network"],"backgroundTag":"directory-not-found","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}