Report Lunch Flow sync status and errors like the provider kit

Merged
JA
1d ago
+354-169

Summary

Lunch Flow convergence, C1a: Lunch Flow's syncer now reports status, errors and failures the way the provider kit's shared syncer does (Brex today). This is a reviewed behaviour change of its own, so the later conversion (B7) can move Lunch Flow onto the shared syncer as a pure move.

Part of #5003 (Track B, Lunch Flow convergence, decided 2026-11-16).

Stacked on #5236. Fork pre-flight: jaysbeekay/sure#726 (same branch, same commit; its CI, Gatekeeper review and screenshot history live there).

Behaviour delta (Lunch Flow)

BeforeAfter
Status texthard-coded English stringslunchflow_items.syncer.* translations, with the same English wording. "1 accounts need setup..." becomes "1 account needs setup..." (pluralised).
Import failure categorieslunchflow_importaccount_import_error, transaction_import_error, import_error
Import failure messagesprovider_warnings.lunchflow_*lunchflow_items.syncer.accounts_failed / transactions_failed / import_failed_with_error (same wording; the 10 existing translations moved with them). A failure with no counts and no error text now reports "Lunch Flow import failed." where it reported nothing.
A linked account that fails to process, or whose balance sync can't be schedulednot reportedreported as account_processing_error / account_sync_error
An exception during syncthe raw message stored on the sync and its stats, and the exception re-raiseda safe translated message stored and raised as LunchflowItem::Syncer::SafeSyncError (credentials_invalid for an :unauthorized / :access_forbidden API error, otherwise failed). The raw error is logged with its backtrace and sent to Sentry, tagged lunchflow_item_id.
A rejected API keysync error "Invalid API key""Invalid Lunch Flow API key or account permissions". The connection is still flagged requires_update.

Unchanged: the setup counts (total_accounts, linked_accounts, unlinked_accounts), pending_account_setup, the investment data-quality warning, the transaction stats, and the import call (the sync window is C1b).

What changed

  • LunchflowItem::Syncer: rewritten in the shared syncer's shape. Lunch Flow keeps its holdings wording ("Processing transactions and holdings...") and its investment warning.
  • config/locales/models/provider_warnings/*.yml (10 locales): the three lunchflow_* keys removed. config/locales/views/lunchflow_items/*.yml: the same translations added under syncer, plus the new English keys. Other locales fall back to English for the new keys.

Demo data

No demo data needed.

Migration notes

No migration. Existing sync records keep their stored messages and categories; only new syncs use the new ones.

Verification

  • Tests (fail-first): LunchflowItem::SyncerTest's expectations change with the delta above. Eight of its nine tests fail on the old syncer, each on the delta it names:

    • the categories;
    • the safe message and SafeSyncError;
    • the provider's error text;
    • process and schedule failures being reported;
    • the status text coming from translations;
    • the rejected-key message.

    The healthy-import test passes before and after.

  • Mutations, each caught: process failures not collected; schedule failures not collected; credential errors not recognised; a hard-coded status; the original exception re-raised; the provider's error text ignored; the old lunchflow_import category.

  • Lunch Flow model, controller and i18n tests: 86 runs, 0 failures.

  • bin/rails test (full, at the C1a commit): 16,309 runs, 0 failures; the same 8 ReleaseNotesWorkflowTest errors (no node in the test image).

  • bin/rubocop on changed files: no offenses. bin/brakeman: no warnings. All changed locale files parse.

  • Size: non-test +218 / -136, of which the syncer is +108 / -52 and the rest is locale moves.

  • Checked against upstream AGENTS.md (blob 1a5dbebd, 2026-11-17): no deviations.

Blast radius

  • LunchflowItem::Syncer is reached only through Syncable#syncer from Sync#perform.
  • The moved translation keys had no other reader.
  • Siblings: Mercury's syncer has the same shape; it converges in its own slice.

Summary by cubic

Converges Lunch Flow's sync reporting with the provider kit: status text and sync errors now come from lunchflow_items.syncer.* translations, and raised exceptions are stored and re-raised as safe SafeSyncError messages instead of raw ones.

Behavior changes

  • Status text uses translations, fixing pluralisation (1 account needs setup instead of 1 accounts need setup).
  • Import failure categories become account_import_error, transaction_import_error, import_error; a failure with no counts and no error text now reports "Lunch Flow import failed."
  • Account processing and balance-sync scheduling failures are now reported, and rejected API keys show "Invalid Lunch Flow API key or account permissions".
  • Failed syncs write a debug log entry with the item id and error class, and the raw error is sent to Sentry.
  • The existing 10 locale translations moved under the new keys; other locales fall back to English.