Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with listing blobs by using of ListBlobsHierarchy() #16295

Closed
an2deg opened this issue Nov 26, 2021 · 11 comments · Fixed by #16354
Closed

Problem with listing blobs by using of ListBlobsHierarchy() #16295

an2deg opened this issue Nov 26, 2021 · 11 comments · Fixed by #16354
Assignees
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Storage Storage Service (Queues, Blobs, Files)

Comments

@an2deg
Copy link

an2deg commented Nov 26, 2021

Bug Report

  • import path of package in question github.com/Azure/azure-sdk-for-go/sdk/storage/azblob
  • SDK version
    github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.12.0
    github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.2.0
    github.com/Azure/azure-sdk-for-go/sdk/to v0.1.1 // indirect
    github.com/aws/aws-sdk-go v1.40.45
  • Go version: go version go1.16.6 darwin/amd64
  • Azurite: mcr.microsoft.com/azure-storage/azurite:3.14.3

In my code I'm invoking ContainerClient.ListBlobsHierarchy() to iterate over a list of blobs in an Azure Blob container.
I'm using azure-sdk-for-go in combination with Azurite.

However, tests fail with error get response from Azure API: no Host in request URL.

I started troubleshooting and found out that containerClient.ListBlobHierarchySegment() on the next call of NextPage() is passing test-fixtures-TestAzBlobClient_ListObjects-2021-11-26T114346.107911+0100/test.csv.1 into runtime.NewRequest() as value of parameter endpoint.

I'm wondering is it problem of Azurite which doesn't compose NextMarker properly or it's problem of ListBlobHierarchySegment() which doesn't respect containerClient configuration ?

Here is a screenshot of debugger demonstrating the process of troubleshooting:

image

My code:

                 perPageConv := int32(2)

		listOptions := &azblob.ContainerListBlobHierarchySegmentOptions{
			Prefix: &prefix,
			Maxresults: &perPageConv,
		}
		azPager := azClient.ListBlobsHierarchy("/", listOptions)

                for {
			hasNext := azPager.NextPage(ctx)
                         if azErr := azPager.Err(); azErr != nil { 
				fmt.Println("get response from Azure API: ", azErr.Error())
				break
                        }

			page := azPager.PageResponse()

			for i, commonPrefix := range page.Segment.BlobPrefixes {
                                 fmt.Println("Blob prefix ", commonPrefix.Name)
			}

			for i, keyObject := range page.Segment.BlobItems {
                                 fmt.Println("Blob ", keyObject.Name)
			}

			if !hasNext {
				break
			}

			pageNo++
		}
@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Nov 26, 2021
@an2deg
Copy link
Author

an2deg commented Nov 26, 2021

I have just checked on real Azure env and the problem is the same: after requesting the second page I get :

2021/11/26 13:48:25 list blobs:  operational: get response from Azure API: no Host in request URL

The same problem is with ListBlobsFlat()

@an2deg
Copy link
Author

an2deg commented Nov 30, 2021

@kenegozi may I ask you to take a look to this issue? Labels in this issue are incorrect: it's not a question but a bug report and the issue is a serious one.

@adreed-msft
Copy link
Member

Currently looking.

@adreed-msft
Copy link
Member

Looks like the generated code is incorrect. Seems to be supplying the entire marker as the new URI. I'm going to shoot out a PR to override this incorrect behavior.

@RickWinter RickWinter added bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library. Storage Storage Service (Queues, Blobs, Files) and removed question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Dec 1, 2021
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Dec 1, 2021
@RickWinter RickWinter added this to the [2022] January milestone Dec 1, 2021
@an2deg
Copy link
Author

an2deg commented Dec 2, 2021

Thank you @adreed-msft for looking at this issue. I cannot test your PR as there are broken dependencies. Will test when your PR be merged.

$ go get github.com/Azure/azure-sdk-for-go/sdk/storage/azblob@adreed/fix-pagers
go: downloading github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.1.1-0.20211201002034-a166c1381cd2
go: downloading github.com/Azure/azure-sdk-for-go v58.3.1-0.20211201002034-a166c1381cd2+incompatible
# github.com/Azure/azure-sdk-for-go/sdk/storage/azblob
../../../Library/Go/pkg/mod/github.com/!azure/azure-sdk-for-go/sdk/storage/[email protected]/zc_append_blob_client.go:17:47: undefined: azcore.Credential
../../../Library/Go/pkg/mod/github.com/!azure/azure-sdk-for-go/sdk/storage/[email protected]/zc_blob_client.go:17:9: undefined: azcore.Credential
../../../Library/Go/pkg/mod/github.com/!azure/azure-sdk-for-go/sdk/storage/[email protected]/zc_blob_client.go:21:41: undefined: azcore.Credential
../../../Library/Go/pkg/mod/github.com/!azure/azure-sdk-for-go/sdk/storage/[email protected]/zc_block_blob_client.go:31:46: undefined: azcore.Credential
../../../Library/Go/pkg/mod/github.com/!azure/azure-sdk-for-go/sdk/storage/[email protected]/zc_connection_string.go:38:62: undefined: azcore.Credential
../../../Library/Go/pkg/mod/github.com/!azure/azure-sdk-for-go/sdk/storage/[email protected]/zc_container_client.go:18:9: undefined: azcore.Credential
../../../Library/Go/pkg/mod/github.com/!azure/azure-sdk-for-go/sdk/storage/[email protected]/zc_container_client.go:27:51: undefined: azcore.Credential
../../../Library/Go/pkg/mod/github.com/!azure/azure-sdk-for-go/sdk/storage/[email protected]/zc_page_blob_client.go:23:45: undefined: azcore.Credential
../../../Library/Go/pkg/mod/github.com/!azure/azure-sdk-for-go/sdk/storage/[email protected]/zc_service_client.go:30:9: undefined: azcore.Credential
../../../Library/Go/pkg/mod/github.com/!azure/azure-sdk-for-go/sdk/storage/[email protected]/zc_service_client.go:40:47: undefined: azcore.Credential
../../../Library/Go/pkg/mod/github.com/!azure/azure-sdk-for-go/sdk/storage/[email protected]/zc_service_client.go:40:47: too many errors

@mohsha-msft
Copy link
Contributor

mohsha-msft commented Dec 3, 2021

Hey @an2deg ,

Can you try

go get github.com/Azure/azure-sdk-for-go/sdk/storage/azblob@dev-azblob

dev-azblob is our development branch and I've merged the changes there.
In general, go get @ is the command to get a specific version or commit-id instead of main branch.

@an2deg
Copy link
Author

an2deg commented Dec 6, 2021 via email

@mohsha-msft
Copy link
Contributor

Hey @an2deg ,

What's the version of Golang you're using?
Can you try go get github.com/Azure/azure-sdk-for-go/sdk/storage/azblob@b76e8f674ad2125742c244cfc8faa417202525bf

or go get github.com/Azure/azure-sdk-for-go/sdk/storage/azblob@dev-azblob

@an2deg
Copy link
Author

an2deg commented Dec 6, 2021 via email

@whati001
Copy link

I have faced the same issue when executing the sample code from the README.md
Pulling the dev release go get github.com/Azure/azure-sdk-for-go/sdk/storage/azblob@dev-azblobfixed the issue for me. Is there already a date fixed when this fix will be merged into the official release?

@mohsha-msft
Copy link
Contributor

Fixed in sdk/storage/azblob/v0.3.0

@github-actions github-actions bot locked and limited conversation to collaborators Apr 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Storage Storage Service (Queues, Blobs, Files)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants