Skip to content

Fix LRO poller to treat HTTP 404/406 as transient during transaction-status polling#46310

Open
Copilot wants to merge 4 commits intomainfrom
copilot/fix-lro-poller-transaction-status
Open

Fix LRO poller to treat HTTP 404/406 as transient during transaction-status polling#46310
Copilot wants to merge 4 commits intomainfrom
copilot/fix-lro-poller-transaction-status

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 14, 2026

  • Understand what was changed and what the reviewer wants restored
  • Restore _not_found_count field in BaseStatePollingMethod
  • Restore original ResourceNotFoundError retry logic (with counter) in sync StatePollingMethod.run()
  • Add separate HttpResponseError catch for 406 in sync StatePollingMethod.run()
  • Do the same for async AsyncStatePollingMethod.run()
  • Update tests to match restored retry semantics (404 limited to 3 retries, 406 unlimited)
  • Run tests to validate — 19 tests passing

…ion-status polling

Agent-Logs-Url: https://github.com/Azure/azure-sdk-for-python/sessions/6789a40b-e0da-4d5e-9cce-6cd42b9b4bd1

Co-authored-by: PallabPaul <20746357+PallabPaul@users.noreply.github.com>
Copilot AI requested a review from PallabPaul April 14, 2026 18:53
@PallabPaul PallabPaul marked this pull request as ready for review April 14, 2026 18:55
Copilot AI review requested due to automatic review settings April 14, 2026 18:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adjusts the Confidential Ledger LRO poller behavior so that HTTP 404 and 406 during transaction-status polling are treated as transient (with different retry semantics), and adds regression tests to lock in the expected behavior.

Changes:

  • Treat HttpResponseError with status code 406 as transient during polling when retry_not_found=True (sync + async).
  • Restore/maintain 404 retry counter behavior (give up after 3 404s) while keeping InvalidTransactionId as non-retryable.
  • Add new pytest suite covering sync/async 404 + 406 retry scenarios.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
sdk/confidentialledger/azure-confidentialledger/tests/test_polling.py Adds sync + async regression tests for transient 404/406 polling behavior.
sdk/confidentialledger/azure-confidentialledger/azure/confidentialledger/_operations/_patch.py Adds explicit HttpResponseError handling for 406 in sync poller loop.
sdk/confidentialledger/azure-confidentialledger/azure/confidentialledger/aio/_operations/_patch.py Adds explicit HttpResponseError handling for 406 in async poller loop.

Comment on lines 113 to 114
if not_retryable or self._not_found_count >= 3:
raise
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

The code enforces the 404 retry limit using a monotonic _not_found_count, but the tests/docstrings describe the behavior as '3 consecutive 404s'. As implemented, non-consecutive 404s (e.g., 404 → 406 → 404 → 406 → 404) will still eventually hit the limit and fail. Please either (a) reset _not_found_count after any successful poll / any non-404 attempt (including the 406 transient path) to make it truly 'consecutive', or (b) update the docstrings/tests to explicitly state the limit is on the total number of 404s during a polling run.

Copilot uses AI. Check for mistakes.
return {"state": "Committed"}

poller = StatePollingMethod(operation, "Committed", 0, retry_not_found=True)
poller._status = "polling"
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

Tests are directly mutating the internal _status field, which makes them brittle to internal refactors (e.g., if the polling method changes how it tracks lifecycle state). Prefer driving the poller via its public surface (e.g., calling the appropriate initializer/start mechanism on the polling method/poller) or using a helper factory that performs whatever public setup is required, so the tests validate behavior rather than internal implementation details.

Copilot uses AI. Check for mistakes.
Comment on lines +95 to +102
def operation():
raise _make_resource_not_found()

poller = StatePollingMethod(operation, "Committed", 0, retry_not_found=True)
poller._status = "polling"

with pytest.raises(ResourceNotFoundError):
poller.run()
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

This test intends to validate the 'give up after 3 retries' behavior, but it never asserts how many times operation() was invoked. Consider adding a call_count counter (as done in other tests) and asserting it equals 3 (or 4, depending on whether your definition is 'retries' vs 'attempts'), so the test actually guards the retry-limit semantics rather than only asserting that a failure eventually occurs.

Copilot uses AI. Check for mistakes.
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.

3 participants