Derive panel syncable types from connection declarations
Merged
JA
2d ago+49+49+01234567890123456789-56-56-01234567890123456789
Summary
Provider kit Track A, A2: Settings::ProvidersController::PANEL_SYNCABLE_TYPES is derived from the adapters' connection declarations instead of hand-kept.
Part of #5003
Stacked on #5005 (A1), in Track A's native stack on #5005.
Fork pre-flight: jaysbeekay/sure#686 (same commits, against a mirror of upstream main; its CI, Gatekeeper and review history live there).
What changed
PANEL_SYNCABLE_TYPES= the connection declarations whose key is inFAMILY_PANEL_KEYS, askey => item class.FAMILY_PANELSitself stays hand-kept until A3.#syncfinds the key instead of indexing the hash withparams[:provider_key], the patternconnect_formalready uses forFAMILY_PANELS: once the hash is not a literal, Brakeman flags the indexed lookup as UnsafeReflection (the class name never comes from the param).- The
provider:familygenerator no longer patches the hash (append_panel_syncable_typeremoved); a generated adapter already declares its connection. Its two tests now coverfamily_panel_itemsonly;docs/api/rails_provider_generator.mdupdated.
No visible change.
Demo data
No demo data needed.
Migration notes
No migration.
Verification
- Old vs new (Rails runner against the removed literal): 26 = 26 entries, equal as a hash.
- New tests: every family panel maps to its own
Syncable<key>_itemsmodel;POST syncfor a provider without a panel (Plaid) schedules nothing. The Plaid test is a boundary guard for the new lookup and passes before the change too. - Mutations, each caught: no panel filter (all 28 declarations); a panel provider without a declaration; the wrong declaration field as the type; Brex declaring Mercury's item class.
eager_load!thenPANEL_SYNCABLE_TYPES.size= 26.bin/rails test(full): 15,867 runs, 0 failures; 8 errors inReleaseNotesWorkflowTestfromnodemissing in the test image. After rebasing the stack onto upstreammain(dbeebf14c), the full suite at the top of the stack (A9): 16,246 runs, 0 failures, the same 8 environment errors.bin/rubocopon changed files: no offenses.bin/brakeman: no warnings.
Blast radius
PANEL_SYNCABLE_TYPESreaders:#sync(unknown or panel-less keys still redirect with no notice) andcompute_provider_sync_health(iterates pairs; order irrelevant).- The generator: one fewer patched list;
FAMILY_PANELS,family_panel_itemsandprovider_summaryare still patched until their own Track A changes.
Summary by cubic
Derives Settings::ProvidersController::PANEL_SYNCABLE_TYPES from the adapters' connection declarations instead of a hand-kept hash, so sync support follows a panel's declaration automatically. No visible behavior change.
Refactors
PANEL_SYNCABLE_TYPESis built from connection declarations whose key is inFAMILY_PANEL_KEYS, mapping keys to item classes.#syncfinds its key withfindinstead of indexing the hash withparams[:provider_key], which Brakeman reads as the param choosing the class to constantize.- The
provider:familygenerator no longer patches the hash; a generated adapter already declares its connection. - New tests verify every family panel maps to its own syncable item model (via
sync_later) and that syncing a non-panel provider schedules nothing.
Summary by CodeRabbit
- Bug Fixes
- Sync controls now reflect the providers available in the settings panel. Attempting to sync a provider without a panel entry no longer queues a sync or displays a success notice.
- Documentation
- Updated provider setup guidance to clarify how connection declarations determine sync status and the availability of the Sync button.