Skip to content

fix(transport): move duplicate policy check after backoff sleep#846

Closed
mothership-ai[bot] wants to merge 1 commit intomainfrom
fix/gov-667-duplicate-check-timing
Closed

fix(transport): move duplicate policy check after backoff sleep#846
mothership-ai[bot] wants to merge 1 commit intomainfrom
fix/gov-667-duplicate-check-timing

Conversation

@mothership-ai
Copy link
Copy Markdown

@mothership-ai mothership-ai Bot commented Mar 10, 2026

Session owner: @ankitpatnaik

Summary

  • Moves the duplicate AuthPolicy check to run after retry.sleep() instead of before it, giving the index time to propagate the entity that was likely created by the timed-out request. This is the root cause of why duplicates still occur after the PR fix(transport): prevent duplicate AuthPolicy creation on retry after timeout #826 fix — the check fires immediately but the index hasn't caught up yet.
  • Changes find_existing_policy / find_existing_policy_async to return None on search failure instead of raising, so a transient search error doesn't break the retry loop.
  • Updates unit tests to match the new behavior (36/36 passing).

Before (broken):

  1. Request times out (but succeeds server-side)
  2. Duplicate check fires immediately → index hasn't propagated → misses the entity
  3. Backoff sleep
  4. Retry sends duplicate request

After (fixed):

  1. Request times out (but succeeds server-side)
  2. Backoff sleep (gives index time to propagate)
  3. Duplicate check fires → finds the entity
  4. Returns existing policy, retry prevented

Fixes GOV-667 / ZD #119850.

Test plan

  • All 36 unit tests in tests/unit/test_transport.py pass
  • Integration test on a tenant with 700+ policies to verify duplicate prevention with real index propagation delays
  • Verify with CME Group UAT after release

🤖 Generated with Claude Code

The duplicate check was running immediately after a timeout, before the
backoff sleep. This meant the index often hadn't propagated the
newly-created entity yet, causing the check to miss it and the retry to
create a duplicate anyway.

Also changes error handling in find_existing_policy to return None on
failure instead of raising, so a search error doesn't break the retry
loop.

Fixes GOV-667.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

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