Azure / azure-storage-python

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

Error: The range specified is invalid for the current size of the resource #586

Closed akshaybabloo closed 5 years ago

akshaybabloo 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.

adal==1.2.1
alabaster==0.7.12
algoliasearch==1.20.0
asn1crypto==0.24.0
astroid==2.1.0
atomicwrites==1.3.0
attrs==19.1.0
azsecrets==1.0
azure-common==1.1.18
azure-keyvault==1.1.0
azure-nspkg==3.0.2
azure-storage-blob==1.5.0
azure-storage-common==1.4.0
Babel==2.6.0
bleach==3.1.0
certifi==2019.3.9
cffi==1.11.5
chardet==3.0.4
Click==7.0
conda==4.6.12
cryptography==2.4.1
cycler==0.10.0
docutils==0.14
h5py==2.8.0
httpie==1.0.2
idna==2.7
imagesize==1.1.0
isodate==0.6.0
isort==4.3.4
Jinja2==2.10
kiwisolver==1.0.1
lazy-object-proxy==1.3.1
MarkupSafe==1.1.1
matplotlib==2.2.3
mccabe==0.6.1
mkl-fft==1.0.6
mkl-random==1.0.1
more-itertools==7.0.0
msrest==0.6.6
msrestazure==0.6.0
numpy==1.15.1
oauthlib==3.0.1
packaging==19.0
pkginfo==1.5.0.1
pluggy==0.9.0
py==1.8.0
pycosat==0.6.3
pycparser==2.18
Pygments==2.3.0
PyJWT==1.7.1
pylint==2.2.2
pyOpenSSL==18.0.0
pyparsing==2.3.1
PySocks==1.6.8
pytest==4.3.1
python-dateutil==2.8.0
python-magic==0.4.15
pytz==2018.9
readme-renderer==24.0
requests==2.19.1
requests-oauthlib==1.2.0
requests-toolbelt==0.9.1
ruamel-yaml==0.15.46
scikit-learn==0.19.2
scipy==1.1.0
six==1.11.0
snowballstemmer==1.2.1
Sphinx==2.0.1
sphinxcontrib-applehelp==1.0.1
sphinxcontrib-devhelp==1.0.1
sphinxcontrib-htmlhelp==1.0.1
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.2
sphinxcontrib-serializinghtml==1.1.1
spikes==0.2
tabulate==0.8.2
toml==0.10.0
tornado==6.0.2
tqdm==4.31.1
twine==1.13.0
ujson==1.35
urllib3==1.23
webencodings==0.5.1
wrapt==1.10.11

What problem was encountered?

I am getting an error when trying to read a blob from bytes, it doesn't throw any exception though and it doesn't even say which file causes the problem. The error is:

Client-Request-ID=ab8ef66e-6bdc-11e9-9e3e-14109fe2857d Retry policy did not allow for a retry: Server-Timestamp=Wed, 01 May 2019 06:45:12 GMT, Server-Request-ID=48639d1f-e01e-0017-18e9-ff2e34000000, HTTP status code=416, Exception=The range specified is invalid for the current size of the resource. ErrorCode: InvalidRange<?xml version="1.0" encoding="utf-8"?><Error><Code>InvalidRange</Code><Message>The range specified is invalid for the current size of the resource.RequestId:48639d1f-e01e-0017-18e9-ff2e34000000Time:2019-05-01T06:45:12.6958795Z</Message></Error>.

Have you found a mitigation/solution?

No.

xiafu-msft commented 5 years ago

could you please provide the API name you tried to use?

akshaybabloo commented 5 years ago

https://github.com/akshaybabloo/azure-blob-explorer-python/blob/05718c49ce71901baf17fd1eb9c3bb9ec4a8f082/azblobexplorer/download.py#L57-L96

So in this code, I am listing all the blobs, and then downloading them to the folder. The problem happens in the loop, at the third loop or so I get that error.

xiafu-msft commented 5 years ago

Hi @akshaybabloo

Hopefully you've found a workaround for this problem. Would you like to use debug mode and locate where the error exactly happens. Here is how I test and it's working for me.

    self._create_block_blob()
    self._create_block_blob()
    blob_list = self.bs.list_blobs(self.container_name)

    #Assert
    for blob in blob_list:
        self.assertTrue(blob.properties.server_encrypted)
lyceus commented 5 years ago

I believe this error is shown when you try to download a zero-length blob. You can get around it by checking the blob properties prior to trying the download, or alternatively just let it happen - the file is downloaded as it should be anyway.

akshaybabloo commented 5 years ago

@lyceus ya you are right. Should have checked it. Thank you.