Skip to content

fix(settings): clear revealed DB connection DSN when switching DB nodes - #356

Merged
zjy365 merged 1 commit into
mainfrom
fix/db-settings-reveal-leak
Sep 18, 2026
Merged

zjy365 merged 1 commit into
mainfrom
fix/db-settings-reveal-leak

Conversation

@zjy365

@zjy365 zjy365 commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Problem

Follow-up to #355, found in product testing: reveal the connection string on one DB's Settings pane (the eye on a Connection Address row), then switch to another DB node — the new DB's connection row still displayed (and copied) the previous DB's full DSN.

Root cause

Two conditions in the DB Settings connection rows:

  • useRevealedRow keeps the revealed DSN for REVEAL_DURATION_MS (30s) and its state lives in useDatabaseSettingsSections, which is reused in place when the pane retargets (fix(settings): revalidate DB resource claims when switching DB nodes #355 made the pane retarget correctly, but reveal state still carried over).
  • The row key is getDatabaseNodeConnectionKeyconnection.id"private"/""public"" — identical across every DB Service, so the stale reveal matched the next DB's row.

Fix

  • Scope the settings rows' keys by workload identity (${namespace}/${name}:private) so a reveal can never match another DB's row.
  • useRevealedRow now exposes clearRevealedRow; useDatabaseSettingsSections clears the revealed row when the workload identity changes, so the secret is dropped from state at the switch instead of lingering for the rest of the 30s window.

Testing

New regression test in db-settings-node-switch.test.tsx: reveal the postgres DSN → switch to redis → the postgres DSN must not render (the row falls back to its mask); revealing on redis resolves the redis DSN. Verified it fails on main with "the postgres DSN must not render on the redis pane" and passes with the fix.

Also added explicit unmounts to the pane tests (the revealed-DSN tooltip tree was leaking across tests without them).

bun test src/features/resource-settings/ — 253 pass; packages/api — 15 pass; bun typecheck, bun check clean.

Follow-up to #355. Revealing a connection string on the DB Settings pane
left the DSN in useRevealedRow state for 30s while the pane retargets in
place, and the row key was connection.id (private/public) — identical
across every DB Service. Switching nodes within the reveal window made
the next DB's connection row display (and copy) the previous DB's full
DSN.

Scope the settings rows' keys by workload identity so a reveal can never
match another DB's row, and clear the revealed row when the identity
changes (useRevealedRow now exposes clearRevealedRow) so the secret does
not linger in state after the switch.
@zjy365
zjy365 merged commit b1c3b3d into main Sep 18, 2026
6 checks passed
@zjy365
zjy365 deleted the fix/db-settings-reveal-leak branch September 18, 2026 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant