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 CDK bug causing incorrect pagination #40718

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -314,16 +314,23 @@ def _read_page(
stream_state: Mapping[str, Any],
stream_slice: StreamSlice,
) -> Iterable[StreamData]:
response = self._fetch_next_page(stream_state, stream_slice)
yield from records_generator_fn(response)

if not response:
next_page_token: Mapping[str, Any] = {FULL_REFRESH_SYNC_COMPLETE_KEY: True}
else:
next_page_token = self._next_page_token(response) or {FULL_REFRESH_SYNC_COMPLETE_KEY: True}
pagination_complete = False
next_page_token = None
# NEW
while not pagination_complete:
response = self._fetch_next_page(stream_state, stream_slice, next_page_token)
yield from records_generator_fn(response)
if not response:
pagination_complete = True
else:
next_page_token = self._next_page_token(response)
if not next_page_token:
pagination_complete = True

if self.cursor:
self.cursor.close_slice(StreamSlice(cursor_slice=next_page_token, partition=stream_slice.partition))
self.cursor.close_slice(StreamSlice(cursor_slice={FULL_REFRESH_SYNC_COMPLETE_KEY: True}, partition=stream_slice.partition))


# Always return an empty generator just in case no records were ever yielded
yield from []
Expand Down
Loading