Repository navigation
feat(declarative): support RequestPath tokens and first-request checks in SyncTokenCursor - #1238
Draft
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
Co-Authored-By: bot_apk <apk@cognition.ai>
Contributor
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
👋 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@devin/1792471568-sync-token-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 devin/1792471568-sync-token-request-pathPR Slash CommandsAirbyte Maintainers can execute the following slash commands on your PR:
|
Patrick Nilan (pnilan)
added this pull request to stack #1236
October 20, 2026 17:11
Collaborator
|
/prerelease
|
This branch was successfully deployed
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.
Overview
👉 TL;DR: Lets the sync-token incremental cursor replay a stored token that is a complete URL (Microsoft Graph delta links), and adds build-time checks so first-request-only token shapes (Box
events) fail with a clear message instead of a request collision on page 2.Specifically,
SyncTokenCursor.token_optionnow acceptsRequestPath,SimpleRetrievergains afirst_request_pathhook with an origin check, the factory validates token/paginator collisions andinject_on_first_request, andSyncTokenCursorcaps stored token state at 4 MB per stream.Resolves https://github.com/airbytehq/airbyte-internal-issues/issues/18023:
Close on merge: yes — internally filed, no customer to confirm with.
This PR is part of a stacked set:
Changes
declarative_component_schema.yaml/ model:SyncTokenCursor.token_optionisanyOf: [RequestOption, RequestPath](Union[RequestOption, RequestPath]).SyncTokenRequestOptionsProvider: returns{}from all request-option methods forRequestPath; newget_request_path(stream_slice)returns the stored token, else renderedinitial_token, elseNone.SimpleRetriever.first_request_path: on the first request of a pass (no paginator path, no page token) the token URL replaces the requester path; paginatorRequestPathlinks still win on later pages. Absolute token URLs whose scheme or host differ from the requester base raise aconfig_errorbefore any request is sent.ModelToComponentFactory:first_request_pathto the innerSyncTokenRequestOptionsProvider(unwrappingPerPartitionRequestOptionsProvider) only forSyncTokenCursor+RequestPath; every other stream getsNone.RequestOptiontoken that sets the same field as the paginator'spage_token_option/page_size_optionunlessignore_stream_slicer_parameters_on_paginated_requests: true.PageIncrement/OffsetIncrementwithinject_on_first_request: truewhen the token goes in the path or on the first request only.SyncTokenCursor:max_state_bytes(default 4 MB) tracked incrementally from partition key + token sizes; stored partitions keep updating, new partitions past the limit are read in full, one WARN per stream.Review Spotlight
Reviewers with limited time, please review first:
simple_retriever.py_paginator_path/_check_token_host: first-request precedence and the origin checkmodel_to_component_factory.pyvalidations: collision and first-request checksReproduction
On the base branch (
4ced6454):SyncTokenRequestOptionsProvider(token_option=RequestPath(...)).get_request_params(...)→AttributeError: 'RequestPath' object has no attribute 'inject_into'.stream_positionas request parameters) → page 2 fails withValueError: Request body collision, duplicate keys detected at key path: stream_position.Risks
RESET_SYNC_TOKEN) with aRequestPathtoken re-reads frominitial_tokenif set, otherwise the requester path — same as theRequestOptionpatterns. A manifest whoseinitial_tokenmeans "sync from now" would skip history on reset; adopters should leaveinitial_tokenunset for Graph.SyncTokenCursorstreams, which are unreleased (this stack).Declarative-First Evaluation
This is a CDK change that adds built-in declarative capability; no connector custom component is written. The adopters (Graph, Box) are manifest-only and could not express this with existing components:
DefaultPaginatorwithRequestPathonly applies after a page token exists (not the first request),RequestOptioncannot carry a full URL, and no existing check catches the token/paginator key collision at build time.Test Coverage
New tests in
test_sync_token_cursor_integration.py(exact URLs/params viaHttpMocker),test_sync_token_cursor.py, andtest_sync_token_request_options_provider.py:T-URL,T-URL-PARAMS,T-URL-INIT,T-URL-RESET,T-URL-PAR,T-ORIGIN,T-POS,T-COLLIDE,T-FIRSTREQ,T-BYTES,T-INERT, plus provider unit tests.unit_tests/: 5820 passed, 22 skipped, 2 failed —test_parse_start_date[date_only_ab_datetime_parse_fallback]and[with_timezone_offset_converted_to_utc], which fail the same way on the base commit4ced6454.ruff check,ruff format --check,mypyon changed files: clean.Versioning
No breaking change: existing
RequestOptionmanifests and the stored state format are unchanged, andRequestPathis an added union member. The CDK version comes from the release process via the conventionalfeattitle; no version file is edited.Follow-ups
docs/platform/connector-development/config-based/understanding-the-yaml-file/incremental-syncs.mdinairbytehq/airbytehas noSyncTokenCursorsection yet (PRs 1234/1235 did not add one), so the RequestPath / first-request guidance from the issue should land with the stack's docs PR.Link to Devin session: https://app.devin.ai/sessions/ef74cd18b819430c89b904a53a3ed78e
Open in Devin Desktop: https://app.devin.ai/desktop/session/ef74cd18b819430c89b904a53a3ed78e?variant=devin