Repository navigation
feat(low-code): expose stream_slice to the paginator interpolation context - #1174
Conversation
…context Pass the slice being read through `SimpleRetriever` and `DefaultPaginator` into `PaginationStrategy.next_page_token`, and add it (with the `stream_interval` / `stream_partition` aliases) to the context of `CursorPagination.stop_condition` and `cursor_value`. Paginators and strategies defined outside the CDK are only handed the slice when their `next_page_token` declares `stream_slice` or `**kwargs`, so existing custom strategies keep working unchanged. Closes #1166 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
👋 Greetings, Airbyte Team Member!Here are some helpful tips and reminders for your convenience. 💡 Show Tips and TricksTesting This CDK VersionYou can test this version of the CDK using the following: # Run the CLI from this branch:
uvx 'git+https://github.com/airbytehq/airbyte-python-cdk.git@tolik0/cdk/paginator-stream-slice#egg=airbyte-python-cdk[dev]' --help
# Update a connector to use the CDK from this branch ref:
cd airbyte-integrations/connectors/source-example
poe use-cdk-branch tolik0/cdk/paginator-stream-slicePR Slash CommandsAirbyte Maintainers can execute the following slash commands on your PR:
|
|
/prerelease
|
…-cdk#1174 prerelease Pin `airbyte-cdk` to `7.30.0.post1.dev35881419701` until #1174 is released, and fill in the changelog PR number. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved review issues were identified, and forwarding and compatibility are covered by tests.
Review effort: Lite
Findings: None
What changed in this PR
This PR exposes the active stream slice to cursor pagination expressions while preserving compatibility with existing custom implementations.
Changes:
- Propagates
stream_slicethrough retrievers, paginators, decorators, and strategies. - Adds slice aliases to cursor and stop-condition interpolation.
- Adds compatibility tests and schema documentation.
| File | Summary |
|---|---|
unit_tests/sources/declarative/retrievers/test_simple_retriever.py |
Tests slice propagation across pagination resets and legacy paginators. |
unit_tests/sources/declarative/requesters/paginators/test_stop_condition.py |
Tests decorator forwarding. |
unit_tests/sources/declarative/requesters/paginators/test_default_paginator.py |
Tests strategy forwarding and compatibility. |
unit_tests/sources/declarative/requesters/paginators/test_cursor_pagination_strategy.py |
Tests slice-dependent expressions. |
airbyte_cdk/sources/declarative/retrievers/simple_retriever.py |
Passes slices during page retrieval. |
airbyte_cdk/sources/declarative/requesters/paginators/strategies/stop_condition.py |
Forwards slices through the decorator. |
airbyte_cdk/sources/declarative/requesters/paginators/strategies/pagination_strategy.py |
Extends the strategy API. |
airbyte_cdk/sources/declarative/requesters/paginators/strategies/page_increment.py |
Accepts the optional slice. |
airbyte_cdk/sources/declarative/requesters/paginators/strategies/offset_increment.py |
Accepts the optional slice. |
airbyte_cdk/sources/declarative/requesters/paginators/strategies/cursor_pagination_strategy.py |
Exposes the slice to interpolation. |
airbyte_cdk/sources/declarative/requesters/paginators/paginator.py |
Adds signature-aware slice forwarding. |
airbyte_cdk/sources/declarative/requesters/paginators/no_pagination.py |
Accepts and ignores the optional slice. |
airbyte_cdk/sources/declarative/requesters/paginators/default_paginator.py |
Propagates slices through paginator decorators. |
airbyte_cdk/sources/declarative/declarative_component_schema.yaml |
Documents slice interpolation variables. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Closes #1166.
What
CursorPagination.stop_conditionandcursor_valuecan now read the slice being paginated, asstream_slice,stream_intervalorstream_partition, the same aliases the requester already offers.Until now a stop condition that depends on the slice (stop once the page is older than the window start) needed a custom
PaginationStrategy, and the slice had to reach it through a side channel. source-github did this by sending the window start in anX-Airbyte-Window-Startrequest header and reading it back off the prepared request (review thread).How
PaginationStrategy.next_page_tokenandPaginator.next_page_tokentake an optionalstream_slice.SimpleRetriever/LazySimpleRetrieverpass the slice each page was read for, including after a pagination reset, throughDefaultPaginator,PaginatorTestReadDecoratorandStopConditionPaginationStrategyDecoratordown to the strategy.CursorPaginationStrategyadds it to the interpolation context ofstop_conditionandcursor_value. The built-inOffsetIncrement,PageIncrementandNoPaginationaccept and ignore it.Backward compatibility
Custom paginators and strategies in connectors override
next_page_token(self, response, last_page_size, last_record, last_page_token_value)without the new parameter.stream_slice_kwargsonly passesstream_slicewhen the callee's signature declaresstream_sliceor**kwargs(cached per function), so those keep working unchanged. This follows the signature-gating used forpage_size_overridein #1149.Tests
CursorPaginationStrategy: a slice-dependentstop_conditionover fresh, stale and empty pages, and acursor_valueread fromstream_partition.DefaultPaginator, the test-read decorator andStopConditionPaginationStrategyDecorator: the slice is forwarded, and a strategy without the parameter is not handed it.SimpleRetriever: after a pagination reset, the paginator sees the slice each page was read for; a paginator without the parameter keeps working.unit_tests/sources/declarative: 2085 passed. ruff and mypy clean.Adopter
airbytehq/airbyte source-github replaces
WorkflowRunsPaginationStrategyand theX-Airbyte-Window-Startheader with astop_condition(PR to follow, pinned to a prerelease of this branch).🤖 Generated with Claude Code