Stop the Lunch Flow panel rendering the stored API key
Summary
The Lunch Flow panel rendered the stored API key into the page. Its API key input used text_field … type: :password with no value: nil, so Rails wrote the decrypted key into the input's value attribute. The browser masks it on screen, but it was in the HTML of the Bank sync drawer and of every Turbo re-render after an update. The field now passes value: nil, as the Brex and Mercury panels already do. Because the form then submits the key blank unless the user types a new one, a blank key no longer overwrites the stored one on update.
This mirrors exactly the Lunch Flow part of the standalone fix for the same leak across several provider panels (branch up/provider-secret-fields, head 91a48d65a, from upstream main 755ce258c; it also fixes CoinStats, Indexa Capital and Sophtron), so this stack rebases cleanly once main has that fix. In this stack Lunch Flow's permitted params live in LunchflowItemsController#item_params, the kit controller subclass since B7b, so the same two lines go there. Brex's and Mercury's panels don't leak.
Part of jaysbeekay/sure#670 (Track B, view layer, owner decision of 2026-11-16: fix the leak before the Lunch Flow views move onto the kit). Stacked on B8c (jaysbeekay/sure#748) in fork stack #687, ahead of the Lunch Flow view slices.
Upstream draft PR: https://github.com/we-promise/sure/pull/5257 (same branch, same commit), in native stack we-promise/sure#5268 on refactor/provider-kit.
Behaviour delta (Lunch Flow)
| Before | After | |
|---|---|---|
| The panel's API key input (drawer and Turbo re-render) | value="<the stored key>" | no value; the placeholder still says "Enter new API key to update" |
| Updating with the API key left blank | overwrote the stored key with "" (latent until now, since the field always resubmitted the key) | keeps the stored key; the other fields still change |
| Updating with a new API key | replaced the key | unchanged |
| The accounts cache on an update without a new key | dropped (the resubmitted key counted as a credential change) | still dropped from the panel: it always submits base_url, which is cache-sensitive too. Kept only for a PATCH that sends neither the key nor base_url. Dropping is the conservative side: one extra provider call, never a stale list. |
| Creating a connection | unchanged | unchanged (a blank key still fails "Api key can't be blank") |
What changed
app/views/settings/providers/_lunchflow_panel.html.erb:value: nilon the API key field.LunchflowItemsController#item_params: drop a blankapi_keyfor a saved connection (the upstream fix's two lines fromlunchflow_params).- Tests: the upstream fix's three
LunchflowItemsControllerTesttests, verbatim and in the same place. Also a Lunch Flow-only connect-form test in a new file; the upstream fix checks the connect form inSettings::ProvidersControllerTesttogether with providers this stack doesn't touch.
Screenshots
Settings > Providers, the Lunch Flow connection from the test fixtures, whose stored API key is test_api_key_123. Before is this PR's base (we-promise/sure#5256's head), after is this PR's head. The masked field looks much the same, so the last column switches the input to type=text in the browser to show the value the page carries: the stored key before, nothing after.
| Light | Dark | Input shown as text | |
|---|---|---|---|
| Before | ![]() | ![]() | ![]() |
| After | ![]() | ![]() | ![]() |
Demo data
No demo data needed.
Migration notes
No migration.
Verification
- Tests (fail-first): on the old code three fail: the re-rendered panel echoing the key, the drawer's connect form echoing it, and a blank submit erasing it. "A new API key replaces the stored key" passes before and after, as a guard.
- Mutations: the field echoing the key again (both render tests catch it); a blank key overwriting (caught). Dropping a blank key on create too survives, because a blank key on create already fails the presence validation, so the two are equivalent.
bin/rails test(full, at this commit): 16,495 runs, 0 failures; the same 8ReleaseNotesWorkflowTesterrors (nonodein the test image).bin/rubocop,erb_lint: no offenses.bin/brakeman: no warnings.- Size: non-test +4 / -2.
- Checked against upstream AGENTS.md (blob 1a5dbebd, 2026-11-17): no deviations.
Blast radius
item_paramsis read by the kit controller'screateandupdatefor Lunch Flow only.- Siblings: Brex's and Mercury's credential fields already pass
value: niland their params already drop a blank token; the other leaking panels are covered by the standalone fix.





