feat(page size reduction): rewrite the page size inside a RequestPath page token URL - #1169
Draft
Anatolii Yatsuk (tolik0) wants to merge 2 commits into
Draft
Anatolii Yatsuk (tolik0) wants to merge 2 commits into
Anatolii Yatsuk (tolik0) wants to merge 2 commits into
Conversation
👋 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/reduce-page-size-request-path#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/reduce-page-size-request-pathPR Slash CommandsAirbyte Maintainers can execute the following slash commands on your PR:
|
… page token URL `page_size_reduction` rejected a `page_token_option` of type RequestPath: the next page is then a full URL built by the API which already carries the page size it echoed back, so the reduced page size was injected next to the original one and the request went out asking for both. `HttpClient._dedupe_query_params` only drops the injected parameter when the two values agree, which is exactly when there is nothing to reduce. `DefaultPaginator.path` now takes the reduced page size and rewrites that parameter inside the token URL, leaving a single page size in the request. Only the parameter named by `page_size_option` is touched and only when the URL already carries it; every other pair is kept byte for byte rather than parsed and re-encoded, so a token URL the API built is handed back as it was written. Whether a page token URL can be re-requested at a smaller page size at all is something only the connector knows - it holds for a URL addressing records by cursor or timestamp, and not for one carrying a page number, where a smaller page size moves every following boundary and skips records the way PageIncrement does. A RequestPath token is opaque to the CDK, so this is opted into with `rewrite_page_size_in_page_token_url` rather than assumed, and the manifest is rejected when the field is set without a RequestPath token or with a page size that does not inject into a request parameter. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Anatolii Yatsuk (tolik0)
force-pushed
the
tolik0/cdk/reduce-page-size-request-path
branch
from
September 18, 2026 15:28
9909693 to
86afff0
Compare
…ion for RequestPath The PageSizeReduction description was updated when rewrite_page_size_in_page_token_url was added, but the field description on SimpleRetriever still said a RequestPath page token is rejected outright. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Stacked on #1149 — review that one first; this branch targets
tolik0/cdk/reduce-page-sizeand its diff is the last commit only.What
Lets
page_size_reductionbe used on a paginator whosepage_token_optionis aRequestPath, by rewriting the page size inside the URL the API returned for the next page instead of sending the reduced page size next to the one that URL already carries. Opted into with a newrewrite_page_size_in_page_token_urlflag onPageSizeReduction.Why
#1149 rejects a
RequestPathpage token at config time. The reason is real, and reproducible onmaintoday:HttpClient._dedupe_query_paramsdrops an injected parameter only when the URL already carries the same value — which is exactly the case where there is nothing to reduce. So with aRequestPathtoken the request goes out asking for both page sizes and the API picks; every page after the first keeps asking for the size that just failed.27 connectors in the monorepo pair a
RequestPathpage token with apage_size_option. The near-term adopter is source-zendesk-supportticket_comments(manifest.yaml:984-995):CursorPaginationonnext_page,page_token_option: RequestPath,page_size_option: per_page, and a504 → RETRYfilter that retries at an unchangedper_pageso the retries cannot succeed.One correction to the #1149 description, which said 3 of those 27 (mendeley, sendgrid, zendesk-support) already handle 502/504: grepping the current manifests, only zendesk-support has any 5xx response filter — mendeley and sendgrid have none. Structurally this unlocks 27 connectors; today exactly one of them has an error path to adopt it for, and that path is a gateway timeout rather than an explicit "page too large" signal. Worth weighing before merging.
How
DefaultPaginator.pathtakespage_size_overrideand rewrites the parameter named bypage_size_optioninside the token URL. Only that pair is edited; the rest of the query is kept byte for byte rather than parsed and re-encoded, so a URL the API built is handed back as it was written (percent-encoding, blank values and bare flags survive).get_request_paramsthen adds the reduced page size the usual way, and appending it to the path would send it twice.paththroughSimpleRetriever._paginator_path, passed withpage_size_override_kwargsso a paginator defined outside the CDK that does not accept the argument keeps working.PaginatorTestReadDecoratorforwards it the same way._dedupe_query_paramsdrops the injected one and a single page size goes out. There is a test asserting exactly that, next to one asserting the duplicated URL without the rewrite.Why it is opt-in
Whether a page token URL can be re-requested at a smaller page size is a property of the API, and a
RequestPathtoken is opaque to the CDK. It holds for a URL addressing records by cursor or timestamp; it does not hold for one carrying a page number, where a smaller page size moves every following page boundary and skips records — the same hazard that makes #1149 rejectPageIncrement. So the connector asserts it rather than the CDK assuming it.Rejected at config time:
rewrite_page_size_in_page_token_urlwithout aRequestPathpage token — there is no URL to rewrite in.rewrite_page_size_in_page_token_urlwith apage_size_optionthat does not inject intorequest_parameter— only a query parameter of that URL can be rewritten.RequestPathpage token without the flag — the existing feat: add REDUCE_PAGE_SIZE response action for dynamic page-size reduction #1149 error, now naming the flag and what has to be true about the API to set it.Scope
Nothing changes for a stream without
page_size_reduction:page_size_overrideisNonefor every other stream, andpathreturns the token unchanged as before. The URL rewrite is reachable only from a reduced page.Testing
DefaultPaginator.path: rewrite, absent parameter, no query, no override, non-request_parameterinjection, repeated parameter, a parameter whose name is a prefix of the page size field, an interpolatedfield_name, a fragment, other parameters returned byte for byte.HttpClient._create_prepared_request: one page size out after the rewrite, two without it.SimpleRetriever: the override reachespath, is omitted when there is none, and_fetch_next_pagesends the rewritten URL.unit_tests/sources/declarativeandunit_tests/sources/streams/httpgreen (2468 passed); the two memory-usage tests were skipped locally, they SIGILL on this machine independently of this branch.No connector adopts this yet; source-zendesk-support would need its
504filter switched toREDUCE_PAGE_SIZEand an SDM prerelease image, since it is manifest-only.