Skip to content

Strange results for download_blob with offset and length #7061

@bryevdv

Description

@bryevdv

Seeing the following results with azure.storage.blob version 12.0.0b2

In [4]: url = "https://bryan.blob.core.windows.net/julia/foo.py" + AZ_SAS_TOKEN

In [5]: bc = BlobClient(url)

In [6]: bc.download_blob().content_as_bytes()
Out[6]: b'class Foo:\n    pass\n\n\nclass Bar:\n    pass\n\n\nclass Baz(object):\n    pass\n'

In [7]: bc.download_blob(offset=0, length=5).content_as_bytes()
Out[7]: b'class '

In [8]: bc.download_blob(offset=5, length=5).content_as_bytes()
Out[8]: b' '

Noting the following unexpected behavior:

  • The first case with offset=0, length=5 returns b'class ' which has length 6
  • The second case with offset=5, length=5 only returns one byte even though there are more than 5 bytes left in the file at that offset

Also there is a typo in the ValueError raised when a length is given without an offset:

raise ValueError("Offset value must not be None is length is set.")

I think that is meant to be "IF length is set" (or perhaps "when length is set")

cc @annatisch @rakshith91 @xiafu-msft @zezha-msft

Metadata

Metadata

Assignees

Labels

ClientThis issue points to a problem in the data-plane of the library.StorageStorage Service (Queues, Blobs, Files)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions