Azure / azure-storage-python

Microsoft Azure Storage Library for Python
https://azure-storage.readthedocs.io
MIT License
338 stars 240 forks source link

AttributeError: '_SharedAccessHelper' object has no attribute 'add_resource_signature' #593

Closed lmazuel closed 5 years ago

lmazuel commented 5 years ago

Which service(blob, file, queue) does this issue concern?

blob

Which version of the SDK was used? Please provide the output of pip freeze.

2.0.0

What problem was encountered?

This code doesn't work anymore in 2.0.0:

        # create a template sas token for the container
        service = BlockBlobService(account_name=storage_account_name,
                                   # don't sign the template with the storage account key use key 00000000
                                   account_key='00000000')
        permissions = ContainerPermissions(read=True, write=True, delete=True, list=True)
        temp_token = service.generate_container_shared_access_signature(container_name='blobcontainer',
                                                                        permission=permissions,
                                                                        expiry='2020-01-01')

Stack trace (enhanced by pytest):

self = <azure.storage.blob.sharedaccesssignature.BlobSharedAccessSignature object at 0x7fd42a8182b0>
container_name = 'blobcontainer'
permission = <azure.storage.blob.models.ContainerPermissions object at 0x7fd42a80c0f0>
expiry = '2020-01-01', start = None, id = None, ip = None, protocol = None
cache_control = None, content_disposition = None, content_encoding = None
content_language = None, content_type = None

    def generate_container(self, container_name, permission=None, expiry=None,
                           start=None, id=None, ip=None, protocol=None,
                           cache_control=None, content_disposition=None,
                           content_encoding=None, content_language=None,
                           content_type=None):

        sas = _SharedAccessHelper()
        sas.add_base(permission, expiry, start, ip, protocol, self.x_ms_version)
        sas.add_id(id)
        sas.add_resource('c')
        sas.add_override_response_headers(cache_control, content_disposition,
                                          content_encoding, content_language,
                                          content_type)
>       sas.add_resource_signature(self.account_name, self.account_key, 'blob', container_name)
E       AttributeError: '_SharedAccessHelper' object has no attribute 'add_resource_signature'

Have you found a mitigation/solution?

No

Note: for table service, please post the issue here instead: https://github.com/Azure/azure-cosmosdb-python.

lmazuel commented 5 years ago

So, the stacktrace lines doesn't match, but still my CI is broken right now, I'm investigating deeper.

xiafu-msft commented 5 years ago

Hi @lmazuel thanks for reaching out, I'm looking into that. I'm pretty sure blob 1.5.0 is working properly, I'm checking out 2.0.0 to test now.

lmazuel commented 5 years ago

So, actually the code is running 1.5.0, the CI shifted 1.5.0 and 2.0.0 last minute because of un unexpected dependency. But still, with 1.5.0 I get that message :/ Still investigating myself

lmazuel commented 5 years ago

@xiafu-msft @zezha-msft I found it. Looking at your release date:

But actually, 1.4.1 common and 1.5.0 are incompatible :(

Looking at your blob/setup.py, it's written "common~=1.4", this means the contract was clear that any 1.4.x common would work forever with blob 1.5.0.

IOW, all installation "pip install azure-storage-blob==1.5.0" are broken as of yesterday

lmazuel commented 5 years ago

I don't know the details of the changes, but I strongly suggest you make a 1.4.2 asap compatible with 1.5.0, to honor the contract committed with the setup.py of 1.5.0. That might mean your changes in 1.4.1 needs to go to a 2.0.0 of common.

zezha-msft commented 5 years ago

Hi @lmazuel, thanks for catching this!

I made a mistake yesterday while looking at the change history, I mistakenly thought that there was no breaking change in common.

I'll fix it asap (in 1-2 hours).

zezha-msft commented 5 years ago

@lmazuel should be fixed now. Could you please re-trigger your CI to verify?

zezha-msft commented 5 years ago

@lmazuel looks like it's been fixed. I'll merge the hot fix branches later. Thanks a bunch! Really sorry for the inconvenience. 😭

lmazuel commented 5 years ago

No problem :). Indeed it works with 1.4.2. Thanks!