Report a failed provider kit sync to Sentry once
Merged
JA
2d ago+62+62+01234567890123456789-69-69-01234567890123456789
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 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; #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.
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.
SafeSyncErroranswersreported?; 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 withsync_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.