* fix(lunchflow): mark sync unhealthy when importer reports fetch failures (#1796)
`LunchflowItem::Syncer#perform_sync` called
`lunchflow_item.import_latest_lunchflow_data` but threw the result away
and then ran `collect_health_stats(sync, errors: nil)`. The importer
already catches per-account 429/500 fetch errors, bumps a
`transactions_failed` counter, and returns `success: false` — but the
syncer never inspected the return value, so the parent sync was marked
completed/green even when zero transactions were imported because every
fetch had been rate-limited.
Capture the importer result and translate any
`accounts_failed` / `transactions_failed` / `error` fields into the
`{ message:, category: }` error shape `collect_health_stats` expects.
The exception-path `rescue` branch is unchanged.
Closes#1796
* test(lunchflow): i18n the new health messages + add syncer invariant tests (#1796)
Two pieces of follow-up feedback:
- @coderabbitai + @JSONbored: the three new operator-facing strings should
go through I18n.t. Add keys under provider_warnings.lunchflow_*
(matching the existing provider_warnings.limited_investment_data
shape) and use Rails pluralization for the count-bearing entries.
Other locales follow the repo's normal translation flow.
- @jjmata + @JSONbored: add tests for the invariants. New
LunchflowItem::SyncerTest covers:
* successful import → sync healthy
* accounts_failed positive → sync unhealthy with localized message
* transactions_failed positive → sync unhealthy with localized message
* both counters positive → both error entries recorded in order
* sync raises → sync_error category + reraise (existing rescue branch)
@jjmata also asked to confirm the importer contract: LunchflowItem::Importer#import
returns 'success: accounts_failed == 0 && transactions_failed == 0' (see
importer.rb), so the early 'return [] if import_result[:success]' guard
is safe — success is never true while either counter is positive.
---------
Co-authored-by: jeffrey701 <jeffrey701@users.noreply.github.com>