azure-sdk-for-python icon indicating copy to clipboard operation
azure-sdk-for-python copied to clipboard

list_blobs / list_blob_names is returning "folder structure"

Open msgerneu opened this issue 1 year ago • 2 comments

  • Package Name: azure-storage-blob
  • Package Version: 12.15.0
  • Operating System: Win + Linux Container
  • Python Version: 3.10.11

Describe the bug list_blobs is return a list of blobs. on some storage accounts it is returning blobs only, but i have one where it also lists "folder structure". for example: for an item like

Aaa/bbb/ccc.txt

I get

Aaa Aaa/bbb Aaa/bbb/ccc.txt

To Reproduce there is no real reproduce, because same code returns different results on storage account. the code is (simplyfied) The starts_with is just a helper to pick one structure, the storage accounts is having tons of files, but the phenomen can be found in all structures.

    sas_token = get_blob_sastoken_account(os.getenv("AN"), os.getenv("AK"))
    account_url = f"https://{os.getenv('AN').lower()}.blob.core.windows.net"
    container = os.getenv("CONTAINER")
    starts_with = os.getenv("STARTS_WITH")

    blob_service_client = BlobServiceClient(account_url=account_url, credential=sas_token)
    container_client = blob_service_client.get_container_client(container)
    blob_list = list(container_client.list_blob_names(name_starts_with=starts_with))

    json_serialize(blob_list,f"starting-{os.getenv('AN')}.json")

Expected behavior Only blobs returned. Folders can not be seperated from real blobs because name or size will lead still to missmatch

Screenshots attached a json dump of list_blobs including metadata as jsonpickle fragment showing above example, with 2 folders and the first file in the structure

Additional context u can contact me directly via internal teams. the-3-stooges.json

msgerneu avatar Mar 12 '24 10:03 msgerneu

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @xgithubtriage.

github-actions[bot] avatar Mar 12 '24 10:03 github-actions[bot]

Thanks for the report @msgerneu! @vincenttran-msft, @jalauzon-msft - is there an account level setting that would cause this?

annatisch avatar Mar 12 '24 20:03 annatisch

i think i found the problem. i need some time for testing, but for now i close it. as i synced with my collegues, they figured out a feature "hierarchical namespace enabled" could be the reason for that

msgerneu avatar Mar 13 '24 08:03 msgerneu