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

Fix pagination of empty response for PaginationType.NONE #524

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dtatarkin
Copy link
Contributor

Library raise StopIteration if endpoint returns an empty list while handle_pagination is PaginationType.NONE

@dtatarkin dtatarkin requested a review from hiohiohio as a code owner November 5, 2024 19:17
@dtatarkin dtatarkin force-pushed the fix-pagination-empty-response branch from b484498 to 55706d7 Compare November 5, 2024 19:19
try:
return next(iterator)
except StopIteration:
return []
Copy link
Contributor

@hiohiohio hiohiohio Nov 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dtatarkin thank you for this PR.
I have noticed that PaginationType.NONE might not work and should not be used without fixed for the current methods/responses.
The issue is that alpaca-py does not return page_token in a response of methods. Therefore, it might easily cause an issue of not noticing actual length of records/data. It might cause a breaking change as well. In the case, raw data/response could be dict instead of list.
I am now considering removing/deprecating PagenationType.NONE rather than fixing with the current spec as we might not have a way to return page_token in a raw data format.

fyi. the other consideration is that this change causes the behaviour change and might cause surprise to existing users. But I wanted to point out the issue above more.

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