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

Return empty array instead of raising NoResultsError for missing results #483

Merged
merged 3 commits into from
Aug 3, 2023

Conversation

justinpolygon
Copy link
Contributor

This PR modifies the _get and _paginate_iter functions to return an empty array instead of raising a NoResultsError when no results are found. This change makes it consistent with the client-go library but more importantly with what users typically expect. By returning an empty array, the code is easier to deal with and understand from a user perspective, and it resolves concerns expressed in two open user issues (#467 and #474).

I have also removed NoResultsError from the code since _get was the only place it was used. _paginate_iter did not correctly handle errors when no results were found. After exploring issue #474, it seems rather than throwing another NoResultsError, we should probably change this for both _get and _paginate_iter to just return an empty array like client-go.

Also, this removes a hurdle for users of the client-python library. In that when they get zero results, their program will crash, they will need to explore why, and then add additional handling and imports. We solve all this upfront by doing what it typically expected.

@justinpolygon justinpolygon merged commit 9f9a3d2 into master Aug 3, 2023
@justinpolygon justinpolygon deleted the jw-empty-array-results branch August 3, 2023 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants