Skip to content

source-shopify-native: fix state reconciliation for resources without backfill tasks#4204

Merged
Alex-Bair merged 4 commits intomainfrom
bair/source-shopify-native-fix-state-reconciliation-again
Apr 7, 2026
Merged

source-shopify-native: fix state reconciliation for resources without backfill tasks#4204
Alex-Bair merged 4 commits intomainfrom
bair/source-shopify-native-fix-state-reconciliation-again

Conversation

@Alex-Bair
Copy link
Copy Markdown
Member

@Alex-Bair Alex-Bair commented Apr 7, 2026

Description:

This PR's scope includes:

  • updating poetry.lock due to the recent changes to estuary-cdk's dependencies in f3351b7 and 640b601.
  • adding pytest-asyncio as a dev dependency so the async tests will run in CI
  • removing async tests that tested unimplemented/undesired behavior & fixing async tests that were broken
  • adding new stores into the resource state in _reconcile_resource_state when the resource does not have a distinct backfill task.

See individual commits for more details.

Confirmed all tests now run in CI. See the snippet below for evidence that no tests were skipped:

Installing the current project: source_shopify_native (0.1.0)
============================= test session starts ==============================
platform linux -- Python 3.12.13, pytest-7.4.4, pluggy-1.6.0
rootdir: /home/runner/work/connectors/connectors
plugins: asyncio-0.23.8, insta-0.3.0, anyio-4.9.0
asyncio: mode=Mode.STRICT
collected 45 items

source-shopify-native/tests/test_snapshots.py ...                        [  6%]
source-shopify-native/tests/test_state_migration.py .................... [ 51%]
......................                                                   [100%]

Update poetry.lock per the recent estuary-cdk package dependency bumps.

Materially for this connector, orjson was bumped from 3.11.1 to 3.11.8.
The async tests in `TestReconcileConnectorState` were being silently skipped
in CI because `pytest-asyncio` was not a dev dependency. `pytest` treated async
def functions as coroutines it couldn't handle and skipped them.

Adding `pytest-asyncio` allows async tests to run in CI now.
…or guards

`test_error_on_invalid_initial_state` and `test_error_on_none_inc_state` expected
`RuntimeError` raises that were not implemented in `_reconcile_connector_state`.
These tests were previously silently skipped in CI since `pytest-asyncio`
was not installed, but those tests fail now that the dependency is present.
Comment on lines -144 to -145
async def test_independent_backfill_addition(self):
"""Backfill is added for a store even when its inc already exists."""
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: the test_independent_backfill_addition test was actually testing behavior that we don't want - backfills shouldn't be added if the associated incremental state already exists; if the incremental state exists but the backfill doesn't, that means the backfill already completed! This PR actually fixed that bug already. This test wasn't updated until now since it never ran in CI without the pytest-asyncio dev dependency.

@Alex-Bair Alex-Bair marked this pull request as ready for review April 7, 2026 18:21
@Alex-Bair Alex-Bair requested a review from nicolaslazo April 7, 2026 18:21
Copy link
Copy Markdown
Contributor

@nicolaslazo nicolaslazo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

…en adding stores

When a new store is added to the endpoint config of an existing capture,
`_reconcile_connector_state` adds it to each resource's state. Right now,
it only added stores to resource states that have both incremental _and_
backfill tasks. But that's insufficient since there are actually some
resources that only have incremental tasks (bulk resources and non-bulk
without `SORT_KEY` have `backfill=None`). The connector currently doesn't
add stores to the state for those incremental-only resources, and that
caused assertion errors in the CDK's `open_binding` function.

This commit fixes that state reconciliation bug. If the store exists in
the incremental state, then no reconciliation is performed. If the store
doesn't exist in the incremental state, then it's added to the incremental
state & it's added to the backfill state if the resource uses a distinct
backfill task.
@Alex-Bair Alex-Bair force-pushed the bair/source-shopify-native-fix-state-reconciliation-again branch from 04c6bfc to 1396ecf Compare April 7, 2026 18:55
@Alex-Bair Alex-Bair merged commit 1a8a432 into main Apr 7, 2026
114 of 127 checks passed
@Alex-Bair Alex-Bair deleted the bair/source-shopify-native-fix-state-reconciliation-again branch April 7, 2026 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants