Skip to content

[Cosmos] Add preview support for change feed previous images - #49063

Draft
Simon Moreno (simorenoh) wants to merge 4 commits into
mainfrom
simorenoh-cosmos-change-feed-previous-images
Draft

Simon Moreno (simorenoh) wants to merge 4 commits into
mainfrom
simorenoh-cosmos-change-feed-previous-images

Conversation

@simorenoh

@simorenoh Simon Moreno (simorenoh) commented Sep 17, 2026

Copy link
Copy Markdown
Member

Description

Adds provisional support for consuming previous item images returned by AllVersionsAndDeletes change feed.

  • Documents the optional previous response member for sync and async change feed APIs.
  • Updates sync and async samples to consume previous images safely.
  • Enables the service preview override in Cosmos emulator CI.
  • Replaces test-side synthesized previous data with validation of the actual response.
  • Expands sync and async coverage for create, replace, delete, continuation replay, and optional previous-image pass-through.

No new SDK request option is introduced because previous-image enablement is service-side, consistent with the .NET implementation.

Closes #49054

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

Targeted sync and async pass-through and live-account AVAD tests pass. Cosmos mypy checks also pass.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 6c56dbeb-5747-439d-80ff-e9e21e3eff34
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
7 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@github-actions

This comment has been minimized.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 6c56dbeb-5747-439d-80ff-e9e21e3eff34
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 6c56dbeb-5747-439d-80ff-e9e21e3eff34
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 6c56dbeb-5747-439d-80ff-e9e21e3eff34
@github-actions

Copy link
Copy Markdown
Contributor
[Pilot] PR Pipeline Failure Analysis

What failed

Azure Pipeline build 6846910 ("python - cosmos - ci") failed on windows2022___EmulatorTestsPython311Standard. One test failed:

  • tests.test_service_retry_policies.TestServiceRetryPolicies.test_service_response_retry_policy

Related checks also reported as failing (same pipeline run family):

  • python - cosmos - ci (Build Test windows2022___EmulatorTestsPython311Standard)
  • python - cosmos - native-test (build 6846909)
  • python - cosmos - native-test (Build Analyze)
  • python - cosmos - native-test (Build Test windows2022___EmulatorTestsPython313Standard)
Relevant pipeline output
tests/test_service_retry_policies.py:200: AssertionError
def test_service_response_retry_policy(self):
    mock_client = CosmosClient(self.host, self.masterKey)
    db = mock_client.get_database_client(self.TEST_DATABASE_ID)
    container = db.get_container_client(self.TEST_CONTAINER_ID)

    created_item = container.create_item({"id": str(uuid.uuid4()), "pk": str(uuid.uuid4())})

    original_location_cache = mock_client.client_connection._global_endpoint_manager.location_cache
    self._setup_read_regions(original_location_cache, [self.REGION1, self.REGION2, self.REGION3])

    mf = self.MockExecuteServiceResponseExceptionIgnoreQuery(Exception, _retry_utility.ExecuteFunction)
    with patch.object(_retry_utility, 'ExecuteFunction', mf):
        with pytest.raises(ServiceResponseError):
            container.read_item(created_item['id'], created_item['pk'])
>           assert mf.counter == 3
E           assert 1 == 3
E            +  where 1 = <test_service_retry_policies.TestServiceRetryPolicies.MockExecuteServiceResponseExceptionIgnoreQuery object at 0x...>.counter

tests	est_service_retry_policies.py:200: AssertionError

Root cause

The failing test (test_service_retry_policies.py) and the ServiceResponseError/ExecuteFunction retry logic it exercises are not touched by this PR. The PR's diff only modifies container.py, _container.py (async), the change-feed samples, test_change_feed_all_versions*.py, and the CI YAML template to enable the AVAD preview override — none of which affect the mocked service-response retry path. The mock's counter only reached 1 instead of the expected 3 calls, which is consistent with a timing/retry-count flake in the region-failover retry mock on the Windows emulator runner rather than a regression from this change.

Recommended next steps

  • Re-run the "python - cosmos - ci" and "python - cosmos - native-test" pipelines; this failure is unrelated to the files changed in this PR and looks like a pre-existing flaky/timing-sensitive emulator test.
  • If it fails again on rerun, investigate test_service_retry_policies.py retry-counting/mocking independently of this PR.
  • See https://aka.ms/ci-fix

Copilot detected the failing pipeline and generated the analysis above. To have it attempt a
fix automatically, reply with @copilot please fix the failing pipeline on this PR.

Generated by Pipeline Analysis Next Steps · auto · 61.3 AIC · ⌖ 2 AIC · ⊞ 9.2K ·

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[Cosmos] Add preview support for previous images in AllVersionsAndDeletes change feed

1 participant