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

bucket.list_blobs(max_results=n) has no effect #1467

Closed
jlowin opened this issue Feb 13, 2016 · 7 comments
Closed

bucket.list_blobs(max_results=n) has no effect #1467

jlowin opened this issue Feb 13, 2016 · 7 comments
Assignees
Labels
api: storage Issues related to the Cloud Storage API. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@jlowin
Copy link

jlowin commented Feb 13, 2016

passing max_results=5 to bucket.list_blobs() appears to have no effect; all blobs are returned in the BlobIterator

@dhermes dhermes added api: storage Issues related to the Cloud Storage API. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Feb 15, 2016
@dhermes
Copy link
Contributor

dhermes commented Feb 15, 2016

Trying to reproduce right now.

@dhermes
Copy link
Contributor

dhermes commented Feb 15, 2016

Confirmed:

>>> list(b.list_blobs(max_results=5))
[<Blob: new1455562849552, a>,
 <Blob: new1455562849552, b>,
 <Blob: new1455562849552, c>,
 <Blob: new1455562849552, d>,
 <Blob: new1455562849552, e>,
 <Blob: new1455562849552, f>]

I'm hoping it's just a query string bug. Digging deeper to ascertain.

@jlowin
Copy link
Author

jlowin commented Feb 15, 2016

@dhermes thanks!

@dhermes
Copy link
Contributor

dhermes commented Feb 15, 2016

Luckily, it's our fault (not the storage backend API). We iterate past the maxResults even when we don't mean to.

A short term fix would be for you to use the iterator manually:

response = blob_iter.get_next_page_response()
results = list(blob_iter.get_items_from_response(response))

Thanks a lot for bringing it to our attention!

@dhermes
Copy link
Contributor

dhermes commented Oct 3, 2016

#1787 should be a reference point for a fix here

@dhermes
Copy link
Contributor

dhermes commented Oct 3, 2016

Another example of unexpected failure:

bucket = Bucket(client, 'my-bucket-name')
blobs = bucket.list_blob(
    max_results=10, page_token=None, fields="items/name,nextPageToken")

for b in blobs:
   print(b.name)

This prints many more than 10 blobs when the iterator is exhausted.

dhermes added a commit to dhermes/google-cloud-python that referenced this issue Oct 4, 2016
In the process, also making sure to lower maxResults
on subsequent requests.

Fixes googleapis#1467.
dhermes added a commit to dhermes/google-cloud-python that referenced this issue Oct 4, 2016
In the process, also making sure to lower maxResults
on subsequent requests.

Fixes googleapis#1467.
@tseaver
Copy link
Contributor

tseaver commented Oct 4, 2016

FTR, #2490 is the first pass at fixing this issue: the solution there may eventually be obsoleted by the general approach sketched recently in #895.

daspecster pushed a commit to daspecster/google-cloud-python that referenced this issue Oct 6, 2016
In the process, also making sure to lower maxResults
on subsequent requests.

Fixes googleapis#1467.
parthea pushed a commit that referenced this issue Jun 4, 2023
In the process, also making sure to lower maxResults
on subsequent requests.

Fixes #1467.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the Cloud Storage API. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

3 participants