Show an import's own error text when it fails without counts

JA
5d ago
+24-1

Summary

Provider kit Track B, K1: when an import fails without per-account counts but its result carries error text, the shared syncer now reports that text instead of a generic "import failed". This is a behaviour change for Brex, the only provider on the kit so far. It is the first convergence step towards moving Lunch Flow and Mercury onto the kit, which report the provider's error today.

Part of jaysbeekay/sure#670 (Track B, convergence decisions, 2026-11-16). Stacked on B5b (jaysbeekay/sure#724) in fork stack #687.

Upstream draft PR: https://github.com/we-promise/sure/pull/5236 (same branch, same commit), in native stack we-promise/sure#5268 on refactor/provider-kit.

Behaviour delta (Brex)

Import resultBeforeAfter
success: false with error: "…" and no per-account counts"Brex import failed.""Brex import failed: …"

Brex's importer rescues BrexError and returns the constant "Failed to fetch accounts data", so today a Brex user sees "Brex import failed: Failed to fetch accounts data", not the provider's own text. Lunch Flow and Mercury pass their provider's text when they move onto the kit. A cap on that text (length, no URLs or tokens) is a follow-up issue, decided before B7/B8.
| success: false with no error text | "Brex import failed." | unchanged |
| per-account or per-transaction failure counts | the count messages | unchanged |

The error category stays import_error. The new message key, brex_items.syncer.import_failed_with_error, is in en only; other locales fall back to English for this one message, which is the existing fallback behaviour.

What changed

  • ProviderItem::Syncer#import_result_errors: with no count failures, it uses <key>_items.syncer.import_failed_with_error (with the provider's text) when the result has an error, and import_failed otherwise.
  • config/locales/views/brex_items/en.yml: the new key.

Demo data

No demo data needed.

Migration notes

No migration.

Verification

  • Contract (fail-first): ProviderItemLifecycleTests adds "a failed import reports the provider's own error when it gives one". It asserts both messages: with the provider's text, and the unchanged generic message without it. Before the change it fails, because the syncer ignored the result's error text ("Brex import failed."). Since 2026-11-17 it also runs error: "" and expects the generic message, so key?(:error) in place of present? fails it.
  • Mutations, each caught: never using the provider's text; always using it.
  • bin/rails test (full, at the K1 commit): 16,305 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.
  • Diff: non-test +4 / -1.
  • Checked against upstream AGENTS.md (blob 1a5dbebd, 2026-11-17): no deviations.

Blast radius

  • ProviderItem::Syncer serves only Brex today. Lunch Flow and Mercury adopt it in their convergence slices, which already show the provider's text.