Skip to content

fix: skip Xero phone sync for merged companies - #514

Merged
corrin merged 1 commit into
mainfrom
fix/merged-company-phone-sync
Aug 1, 2026
Merged

fix: skip Xero phone sync for merged companies#514
corrin merged 1 commit into
mainfrom
fix/merged-company-phone-sync

Conversation

@corrin

@corrin corrin commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Why

Production has 105 AppError rows from sync_xero_phone_methods hard-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 with include_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 with merged_into_id set returns [] before touching phones. The next sync clears the whole backlog at once.

Tests

New test_merged_company_phones_are_not_synced pins the exact prod scenario: winner owns the number, merged company's archived contact still carries it — sync returns [], creates nothing, raises nothing, persists no AppError. All 6 tests in XeroPhoneMethodSyncTests pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PnuHL7w3UisSk6KQ81q3Qf

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
@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@corrin, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 39 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: fb09bbc8-1be2-4e3e-8ec0-2aec89b58dd9

📥 Commits

Reviewing files that changed from the base of the PR and between 6e1371c and 5434647.

📒 Files selected for processing (2)
  • apps/workflow/api/xero/reprocess_xero.py
  • apps/workflow/tests/test_sync_clients.py

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@corrin
corrin merged commit 82d2907 into main Aug 1, 2026
9 checks passed
@corrin
corrin deleted the fix/merged-company-phone-sync branch August 1, 2026 20:37
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.

1 participant