Repository navigation
DataLakeDirectoryClient::ListPaths() throws exception for folders whose names contain spaces. #7475
Description
Describe the bug
DataLakeDirectoryClient::ListPaths() throws Azure::Storage::StorageException exception on folders whose names contain spaces.
For example, we have the code part below. Its throws Azure::Storage::StorageException exception with "404 The specified path does not exist." message, even when specified folder(which name contains space) exist.
DataLakeDirectoryClient cleint = DataLakeDirectoryClient::CreateFromConnectionString(connectionString, containerName, folderPath, options);
client.GetSubdirectoryClient("Test Folder/").ListPaths(includeSubfolders, ListPathsOptions{});
When we use this code part it works correct.
DataLakeDirectoryClient cleint = DataLakeDirectoryClient::CreateFromConnectionString(connectionString, containerName, folderPath + "Test Folder/", options);
client.ListPaths(includeSubfolders, ListPathsOptions{});
My investigation shows the root cause comes from the file ...\azure-sdk-for-cpp-azure-storage-common\sdk\storage\azure-storage-common\src\crypt.cpp and functions UrlEncodeQueryParameter().
Root cause
When we call the ListPaths it has nested call to the _internal::UrlEncodeQueryParameter to encode folder's path.
Meanwhile the GetSubdirectoryClient also has nested call to the function _internal::UrlEncodePath().
As a result, when we make a call client.GetSubdirectoryClient("Test Folder/").ListPaths(includeSubfolders, ListPathsOptions{}) the folder name "Test Folder/" encodes twice. After first encode from the GetSubdirectoryClient() the "Test Folder/" becomes "Test%20Folder/". And after second encode it becomes "Test%2520Folder/". If we decode the last string, it will be "Test%20Folder/", which is incorrect. The decoded path should be same "Test Folder/".
If we added '%' symbol to the doNotEncodeCharacters += "/:@?"; line in the function UrlEncodeQueryParameter(), it should fix the issue.
Exception or Stack Trace
Azure::Storage::StorageException with error message
404 The specified path does not exist.
The specified path does not exist.
RequestId:ec627031-101f-007a-1754-5df83a000000
Time:2026-10-16T09:55:26.3272893Z
Request ID: ec627031-101f-007a-1754-5df83a000000
Code Snippet
DataLakeDirectoryClient cleint = DataLakeDirectoryClient::CreateFromConnectionString(connectionString, containerName, folderPath, options);
client.GetSubdirectoryClient("Test Folder/").ListPaths(includeSubfolders, ListPathsOptions{});
Expected behavior
The folders should be visible and accessible regardless of whether the folder name contains spaces.
Setup (please complete the following information):
- OS: [e.g. Windows]
- IDE : [e.g. Visual Studio Professional 2022]
- Version of the Library used: azure-core_1.16.4, azure-storage-common_12.15.0, azure-storage-files-datalake_12.17.0
Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
- Bug Description Added
- Repro Steps Added
- Setup information Added
encodes
Activity
github-actions commentedon Oct 16, 2026
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc Amanda Nguyen (@amnguye) Gauri Lamunion (@gapra-msft) JinmingHu (@Jinming-Hu).
Jinming-Hu commentedon Oct 17, 2026
I tried this against a live ADLS Gen2 account using the current SDK source (12.18.0-beta.1), but couldn't reproduce the 404.
I created
parent/Test Folderwith a file inside it, then calledGetSubdirectoryClient("Test Folder")on the parent client andListPaths(false)on the returned client. The file was listed correctly. I also triedGetSubdirectoryClient("Test Folder/"), with the trailing slash from your example, and that worked too.The outgoing request had
directory=parent/Test%20Folder, so I didn't see double encoding. I used OAuth authentication and service API version2025-05-05, rather than an account-key connection string, so the setup wasn't identical to yours.Could you try again with the latest published SDK version and let us know whether it still happens? If it does, please share a small complete repro and the package versions you're using, with credentials removed.
HoraceBianchon commentedon Oct 19, 2026
Thanks for the request. I have checked it works in the latest version.