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

sdk/storage/azblob: BlobClient is missing a way to set a lease id in SetTags #17515

Closed
seveas opened this issue Apr 11, 2022 · 3 comments
Closed
Assignees
Labels
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. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Storage Storage Service (Queues, Blobs, Files)

Comments

@seveas
Copy link

seveas commented Apr 11, 2022

Bug Report

When I try to call SetTags for a blob on which I hold a lease, I get the following error:

===== RESPONSE ERROR (ErrorCode=LeaseIdMissing) =====
Description=There is currently a lease on the blob and no lease ID was specified in the request.
RequestId:93ef853f-301e-0033-2c8c-4d411d000000
Time:2022-04-11T10:08:15.3670529Z
Details: (none)

Looking at the rest api docs, I see the lease id must be provided in this case. However, SetTagsBlobOptions is missing fields to do so (and presumably, the code for setting the relevant header is missing as well).

@msftbot msftbot bot added needs-triage 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 Apr 11, 2022
@seveas
Copy link
Author

seveas commented Apr 11, 2022

Patching with the patch below makes it work. This does not work as a PR though, as this changes a generated file and I have no idea how to properly update those:

diff --git sdk/storage/azblob/zc_blob_client.go sdk/storage/azblob/zc_blob_client.go
index 4668047ccf..90fd3be3fa 100644
--- sdk/storage/azblob/zc_blob_client.go
+++ sdk/storage/azblob/zc_blob_client.go
@@ -208,8 +208,8 @@ func (b *BlobClient) AbortCopyFromURL(ctx context.Context, copyID string, option
 // To remove all tags from the blob, call this operation with no tags set.
 // https://docs.microsoft.com/en-us/rest/api/storageservices/set-blob-tags
 func (b *BlobClient) SetTags(ctx context.Context, options *SetTagsBlobOptions) (BlobSetTagsResponse, error) {
-       blobSetTagsOptions, modifiedAccessConditions := options.pointers()
-       resp, err := b.client.SetTags(ctx, blobSetTagsOptions, modifiedAccessConditions)
+       blobSetTagsOptions, leaseAccessConditions, modifiedAccessConditions := options.pointers()
+       resp, err := b.client.SetTags(ctx, blobSetTagsOptions, leaseAccessConditions, modifiedAccessConditions)

        return resp, handleError(err)
 }
diff --git sdk/storage/azblob/zm_blob_request_options.go sdk/storage/azblob/zm_blob_request_options.go
index 7d240e6104..b04d403aa7 100644
--- sdk/storage/azblob/zm_blob_request_options.go
+++ sdk/storage/azblob/zm_blob_request_options.go
@@ -258,11 +258,12 @@ type SetTagsBlobOptions struct {
        TagsMap map[string]string

        ModifiedAccessConditions *ModifiedAccessConditions
+       LeaseAccessConditions    *LeaseAccessConditions
 }

-func (o *SetTagsBlobOptions) pointers() (*BlobSetTagsOptions, *ModifiedAccessConditions) {
+func (o *SetTagsBlobOptions) pointers() (*BlobSetTagsOptions, *LeaseAccessConditions, *ModifiedAccessConditions) {
        if o == nil {
-               return nil, nil
+               return nil, nil, nil
        }

        options := &BlobSetTagsOptions{
@@ -274,7 +275,7 @@ func (o *SetTagsBlobOptions) pointers() (*BlobSetTagsOptions, *ModifiedAccessCon
                VersionID:                 o.VersionID,
        }

-       return options, o.ModifiedAccessConditions
+       return options, o.LeaseAccessConditions, o.ModifiedAccessConditions
 }

 // GetTagsBlobOptions provides set of configurations for GetTags operation
diff --git sdk/storage/azblob/zz_generated_blob_client.go sdk/storage/azblob/zz_generated_blob_client.go
index 05a273cb25..dd9e5bd7fd 100644
--- sdk/storage/azblob/zz_generated_blob_client.go
+++ sdk/storage/azblob/zz_generated_blob_client.go
@@ -2432,8 +2432,8 @@ func (client *blobClient) setMetadataHandleResponse(resp *http.Response) (BlobSe

 // SetTags - The Set Tags operation enables users to set tags on a blob.
 // If the operation fails it returns the *StorageError error type.
-func (client *blobClient) SetTags(ctx context.Context, blobSetTagsOptions *BlobSetTagsOptions, modifiedAccessConditions *ModifiedAccessConditions) (BlobSetTagsResponse, error) {
-       req, err := client.setTagsCreateRequest(ctx, blobSetTagsOptions, modifiedAccessConditions)
+func (client *blobClient) SetTags(ctx context.Context, blobSetTagsOptions *BlobSetTagsOptions, leaseAccessConditions *LeaseAccessConditions, modifiedAccessConditions *ModifiedAccessConditions) (BlobSetTagsResponse, error) {
+       req, err := client.setTagsCreateRequest(ctx, blobSetTagsOptions, leaseAccessConditions, modifiedAccessConditions)
        if err != nil {
                return BlobSetTagsResponse{}, err
        }
@@ -2448,7 +2448,7 @@ func (client *blobClient) SetTags(ctx context.Context, blobSetTagsOptions *BlobS
 }

 // setTagsCreateRequest creates the SetTags request.
-func (client *blobClient) setTagsCreateRequest(ctx context.Context, blobSetTagsOptions *BlobSetTagsOptions, modifiedAccessConditions *ModifiedAccessConditions) (*policy.Request, error) {
+func (client *blobClient) setTagsCreateRequest(ctx context.Context, blobSetTagsOptions *BlobSetTagsOptions, leaseAccessConditions *LeaseAccessConditions, modifiedAccessConditions *ModifiedAccessConditions) (*policy.Request, error) {
        req, err := runtime.NewRequest(ctx, http.MethodPut, client.con.Endpoint())
        if err != nil {
                return nil, err
@@ -2472,6 +2472,9 @@ func (client *blobClient) setTagsCreateRequest(ctx context.Context, blobSetTagsO
        if blobSetTagsOptions != nil && blobSetTagsOptions.RequestID != nil {
                req.Raw().Header.Set("x-ms-client-request-id", *blobSetTagsOptions.RequestID)
        }
+       if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil {
+               req.Raw().Header.Set("x-ms-lease-id", *leaseAccessConditions.LeaseID)
+       }
        if modifiedAccessConditions != nil && modifiedAccessConditions.IfTags != nil {
                req.Raw().Header.Set("x-ms-if-tags", *modifiedAccessConditions.IfTags)
        }

seveas added a commit to seveas/azure-sdk-for-go that referenced this issue Apr 11, 2022
@jhendrixMSFT jhendrixMSFT added the Storage Storage Service (Queues, Blobs, Files) label Apr 12, 2022
@msftbot msftbot bot removed the needs-triage This is a new issue that needs to be triaged to the appropriate team. label Apr 12, 2022
@jhendrixMSFT jhendrixMSFT added Client This issue points to a problem in the data-plane of the library. needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Apr 12, 2022
@msftbot msftbot bot removed the needs-triage This is a new issue that needs to be triaged to the appropriate team. label Apr 12, 2022
@mohsha-msft mohsha-msft self-assigned this Apr 19, 2022
@mohsha-msft
Copy link
Contributor

Hey @seveas ,

Thanks for pointing this out!

I've fixed it and will release the it next release.

@mohsha-msft
Copy link
Contributor

mohsha-msft commented Apr 20, 2022

Hey @seveas ,

azblob v0.4.0 is now publically available. I have fixed the issue here.

Please reach out and reopen the issue if it still persists.

Thanks a lot for your feedbacks!

@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
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. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Storage Storage Service (Queues, Blobs, Files)
Projects
None yet
Development

No branches or pull requests

4 participants