fix: skip Xero phone sync for merged companies - #514
Conversation
A merged company's numbers live on the company it was merged into, but its archived Xero contact keeps the phones and is still fetched with include_archived=True. Every sync then collides with the winner's rows under the one-number-one-company rule, hard-failing the company and persisting an AppError — 105 of them in production. No prod-only remedy exists: blanking the number gets re-synced from Xero, and merging in Xero doesn't strip the archived contact's phones. sync_xero_phone_methods now returns early for a merged company; the next sync clears the whole backlog at once. A test pins the exact collision scenario. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PnuHL7w3UisSk6KQ81q3Qf
|
Warning Review limit reached
Next review available in: 39 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Why
Production has 105
AppErrorrows fromsync_xero_phone_methodshard-failing on merged companies. A merged company's numbers live on the company it was merged into, but its archived Xero contact keeps the phones and is still fetched withinclude_archived=True— so every sync collides with the winner's rows under the one-number-one-company rule.No prod-only remedy works: blanking the number gets re-synced from Xero, and merging in Xero doesn't strip the archived contact's phones. The fix has to be code.
What
One guard at the top of
sync_xero_phone_methods: a company withmerged_into_idset returns[]before touching phones. The next sync clears the whole backlog at once.Tests
New
test_merged_company_phones_are_not_syncedpins the exact prod scenario: winner owns the number, merged company's archived contact still carries it — sync returns[], creates nothing, raises nothing, persists noAppError. All 6 tests inXeroPhoneMethodSyncTestspass.🤖 Generated with Claude Code
https://claude.ai/code/session_01PnuHL7w3UisSk6KQ81q3Qf