Report a failed provider kit sync to Sentry once
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 raises | Before | After |
|---|---|---|
| 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 broadcast | two: 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 error | the safe translated message | unchanged |
| A non-kit syncable's failure | reported once by Sync#report_error with sync_id | unchanged |
What changed
ProviderItem::Syncer::SafeSyncErroranswersreported?.Sync#performskipsreport_errorfor an error that answers it truthfully. Only theperformrescue changes; the post-sync and full-resync rescues report as before.- The syncer's capture adds
sync_id, read withtry, 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 ownSafeSyncErrorclasses 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 withsync_id), a Mercury test (a sync double without an id still raisesSafeSyncError) and the Brex tag test. - Mutations, each caught: dropping the marker check, dropping the
sync_idtag, inverting the check, and readingsync.iddirectly. bin/rails test(full, at this commit): 0 failures. The 8ReleaseNotesWorkflowTesterrors come from the test image having nonode.- rubocop clean. Non-test diff +10 / -4.
- Found on the way, not fixed here: Brex has no
BrexItem::SyncCompleteEvent, so every Brex post-sync raisesNameErrorinto Sentry (also onmain). 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.