Skip to content

"list index out of range" on random releases in search #183

@Suntooth

Description

@Suntooth

I am very new to working with APIs, so apologies if I'm missing something obvious.

I'm searching for releases, then selecting releases from the results with results[i] (not pagination). However, sometimes it throws a "list index out of range" error on specific ranges of releases. I haven't been able to figure out a pattern in which releases, especially since this stops me from being able to get any details about the releases it's happening on.

For example, using the following code:

import discogs_client

d = discogs_client.Client("[redacted]", user_token="[redacted]")

results = d.search(format="Sampler", type="master", genre="Rock", artist="Various")
randomResult = results[396]

throws this error:

Traceback (most recent call last):
  File "[path redacted]", line 6, in <module>
    randomResult = results[396]
                   ~~~~~~~^^^^^
  File "[path redacted]/discogs_client/models.py", line 368, in __getitem__
    return page[offset]
           ~~~~^^^^^^^^
IndexError: list index out of range

For this search, using a value between 396 and 399 (inclusive) threw this error, but 395 and 400 worked. It's not a case of there being less than (in this case) 397 releases in the search, as currently len(results) returns 1129.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions