Report a failed provider kit sync to Sentry once

Merged
JA
2d 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 #5003.

Stacked on #5267. Fork pre-flight: jaysbeekay/sure#924 (same branch, same commit). Fork issue: jaysbeekay/sure#820.

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; #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.


Summary by cubic

A failed provider kit sync reached Sentry as two unlinked events: the raw error tagged with the connection id, then the safe error tagged with the sync id. Now the syncer reports the raw error once, tagged with both ids, and Sync#perform skips its own report for errors already reported.

  • SafeSyncError answers reported?; only the perform rescue checks it. The post-sync and full-resync rescues still report as before.
  • Non-kit syncables, whose errors don't answer reported?, are still reported once with sync_id.
  • The sync id is read with try, so a sync without an id still raises the safe error.
  • Lifecycle contract tests for Brex, Lunch Flow, and Mercury assert one event tagged with both ids, that the raised safe error has no cause, and that the post-sync broadcast is stubbed out of the count. No migration needed.