Skip to content

Commit

Permalink
feat: Auto-detect end of pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Nov 17, 2023
1 parent 2a64cf6 commit 15494ab
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion singer_sdk/streams/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,14 @@ def request_records(self, context: dict | None) -> t.Iterable[dict]:
resp = decorated_request(prepared_request, context)
request_counter.increment()
self.update_sync_costs(prepared_request, resp, context)
yield from self.parse_response(resp)
records = iter(self.parse_response(resp))
try:
first_record = next(records)
except StopIteration:
self.logger.info("No records found in response")
break

Check warning on line 403 in singer_sdk/streams/rest.py

View check run for this annotation

Codecov / codecov/patch

singer_sdk/streams/rest.py#L401-L403

Added lines #L401 - L403 were not covered by tests
yield first_record
yield from records

paginator.advance(resp)

Expand Down

0 comments on commit 15494ab

Please sign in to comment.