Report a failed provider kit sync to Sentry once

JA
5d ago
+62-69

Summary

Provider kit follow-up: a failed kit sync reached Sentry as two unlinked events. The syncer captured the raw error, tagged with the connection id. Sync#perform then captured the SafeSyncError again, tagged with the sync id, so neither event carried both ids. Now there is one event, the raw error, tagged with both.

Part of jaysbeekay/sure#820: this closes it for Lunch Flow and Mercury; Brex's second event comes from the missing BrexItem::SyncCompleteEvent, which we-promise/sure#5517 adds. Part of jaysbeekay/sure#670 (provider kit).

Stacked on jaysbeekay/sure#758. Upstream draft PR: https://github.com/we-promise/sure/pull/5478 (same branch, same commit), in native stack we-promise/sure#5268 on refactor/provider-kit. Appended to fork stack #687.

Behaviour delta (Brex, Lunch Flow, Mercury)

A sync that raisesBeforeAfter
Sentry events (Lunch Flow, Mercury)two: the raw error (<key>_item_id), then SafeSyncError (sync_id)one: the raw error, tagged <key>_item_id and sync_id
Sentry events (Brex)three: the raw error, SafeSyncError, and a NameError from the post-sync broadcasttwo: the raw error tagged with both ids, and the NameError. Brex has no BrexItem::SyncCompleteEvent; we-promise/sure#5517 adds it, which leaves one
The sync's stored errorthe safe translated messageunchanged
A non-kit syncable's failurereported once by Sync#report_error with sync_idunchanged

What changed

  • ProviderItem::Syncer::SafeSyncError answers reported?. Sync#perform skips report_error for an error that answers it truthfully. Only the perform rescue changes; the post-sync and full-resync rescues report as before.
  • The syncer's capture adds sync_id, read with try, so a sync without an id still gets the safe error raised.
  • Duck-typed rather than a class check: only this class answers reported?. Wise, Up, Akahu, Fio and Monobank keep their own SafeSyncError classes and are reported as before.

Verification

  • Fail-first: the lifecycle contract test (Brex, Lunch Flow, Mercury) asserts exactly one event, the raw error, tagged with both ids. Before the change it saw two.
  • Also pinned: SyncTest (a non-kit failure is still reported once with sync_id), a Mercury test (a sync double without an id still raises SafeSyncError) and the Brex tag test.
  • Mutations, each caught: dropping the marker check, dropping the sync_id tag, inverting the check, and reading sync.id directly.
  • bin/rails test (full, at this commit): 0 failures. The 8 ReleaseNotesWorkflowTest errors come from the test image having no node.
  • rubocop clean. Non-test diff +10 / -4.
  • Found on the way, not fixed here: Brex has no BrexItem::SyncCompleteEvent, so every Brex post-sync raises NameError into Sentry (also on main). The contract test stubs the post-sync broadcast to count only the failure's own events. Fork issue: jaysbeekay/sure#921.

Migration notes

No migration.