Return empty array instead of raising NoResultsError for missing results #483
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR modifies the
_get
and_paginate_iter
functions to return an empty array instead of raising aNoResultsError
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 anotherNoResultsError
, 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.