Repository navigation
fix(ui): the SSH toggle read the ops payload one level too shallow, so it inverted the operator's intent (#2411) - #2413
Conversation
…o it inverted the operator's intent (#2411) `GET /api/settings/ops/config` nests settings TWICE, and `Settings.vue` read them flat: { settings: { ssh_access_enabled: { value: "true", default: "false", … } } } `response.data.ssh_access_enabled` is `undefined`, `undefined === 'true'` is `false`, and the switch rendered OFF whatever was stored. Because the click handler computes `!sshAccessEnabled.value`, the FIRST click then always sent `true` — an operator with ephemeral SSH enabled, clicking to DISABLE it, re-enabled it and watched it render as off. The write path was always correct, so the mismatch was one-sided: a change appeared to stick for the session and silently reverted on reload, which is why it went unnoticed. ## The issue's own suggested fix is not sufficient #2411 proposes `response.data.settings?.ssh_access_enabled`. That is still wrong, for the same underlying reason: `get_ops_settings` builds a DESCRIPTOR per key (`value`/`default`/`description`/`is_default`), so it resolves to an object and `object === 'true'` is `false` — the toggle would still have rendered OFF while looking fixed. The `.value` hop is the one that matters. Pinned by its own test so the half-fix cannot be reintroduced as a "simplification". ## Why a pure module rather than a one-line edit `Settings.vue` cannot be mounted in this project's test setup — `@vue/test-utils` is not a dependency and vitest runs `environment: 'node'` — so a rule kept inline is a rule no test can reach. That is exactly how a one-line read bug survived inside a security control, and it is the reason the issue says the value is in the test rather than the fix. `utils/opsSettings.js` owns both spellings: `readOpsBool` for the read and `opsBoolValue` for the write, together in one file instead of at opposite ends of a 3500-line SFC, which is what let them drift in the first place. It accepts the descriptor form and a bare string, since the only thing separating them is a wrapper the reader does not need. Everything unreadable degrades to `false` (AC #4) — absent key, absent `settings`, null payload, a number, `settings` that is not an object. `false` is the SAFE direction: `ssh_access_enabled` defaults to `"false"` server-side, and a security control that cannot read its own state must not claim the permissive one. The endpoint is untouched, per the issue's explicit instruction: `PUT /ops/config` takes the nested shape and the other ops readers depend on the current contract. The endpoint is the side that is right. ## Verification 18 tests, and each side of the fix mutation-checked rather than assumed: - reader reverted to `payload?.[key]` → 4 failed - SFC reverted to the flat read that shipped → 2 failed - restored → 18 passed AC #5 is pinned rather than eyeballed once: a test asserts `ops/config` is read in exactly one place, so a second GET added later has to come through the same reader. Full frontend suite 64 files / 1454 tests; `vite build` clean. Closes #2411 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
obasilakis
left a comment
There was a problem hiding this comment.
/validate-pr — approving.
Correct diagnosis and the fix goes to the right place. Worth stating plainly what this was: a security control that rendered OFF regardless of what was stored, on a UI whose click handler negates the rendered state — so an operator with ephemeral SSH enabled, clicking to disable it, re-enabled it and then watched it render as off. The write path was always right, which is exactly why it looked like it stuck for the session and reverted on reload.
The detail that makes this more than a one-line patch is noticing that the fix the issue itself proposes — response.data.settings?.ssh_access_enabled — is still wrong: it resolves to the descriptor object, and object === 'true' is false. The toggle would have stayed broken while looking fixed, and the test pinning that is the most valuable assertion in the file.
Degrading everything unreadable to false is the right direction for this flag specifically, and the comment says why rather than asserting it.
The axios.get('/api/settings/ops/config') call-count assertion is a good structural pin: it makes a second reader added later come through the same rule instead of re-deriving the shape.
Checklist: base dev, Closes #2411, security scan clean, no packaging or infra surface, no schema change. Docs commit-message-only per the tiered rule. CI green including e2e.
One note, non-blocking: readOpsBool accepts 'TRUE' and ' true ' while the server's validate_ops_setting requires exactly 'true'/'false'. The comment justifies it (a hand-edited DB row should not silently read as false) and the asymmetry is in the tolerant direction on the read side only, so it is fine — just flagging that reader and writer no longer agree on the accepted vocabulary.
theme-security on a P1: this is a frontend read fix and the backend gate on ephemeral SSH minting is untouched, so I did not run /cso --diff over it.
Summary
The SSH access toggle read
GET /api/settings/ops/configflat while the endpoint nests settings twice, so it wasundefined === 'true'on every load: the switch rendered OFF whatever was stored, and since the click handler negates that state, the first click always senttrue— an operator with ephemeral SSH enabled, clicking to disable it, re-enabled it and then watched it render as off.The write path was always correct. The mismatch was one-sided, which is why it looked like a change stuck for the session and silently reverted on reload.
The issue's own suggested fix is not sufficient
#2411 proposes
response.data.settings?.ssh_access_enabled. That is still wrong, for the same underlying reason.get_ops_settingsbuilds a descriptor per key:So
settings.ssh_access_enabledis an object, andobject === 'true'isfalse— the toggle would still have rendered OFF while looking fixed. The.valuehop is the one that matters, and a test pins it so the half-fix cannot come back as a "simplification".Why a pure module rather than a one-line edit
The issue says the value is in the test rather than the fix, and that is only achievable with a seam:
Settings.vuecannot be mounted here —@vue/test-utilsis not a dependency and vitest runsenvironment: 'node'— so a rule kept inline is a rule no test can reach. That is exactly how a one-line read bug survived inside a security control.utils/opsSettings.jsowns both spellings —readOpsBoolfor the read,opsBoolValuefor the write — in one file rather than at opposite ends of a 3500-line SFC, which is what let them drift.Acceptance criteria
false(safe direction)The endpoint is untouched, per the issue's explicit instruction —
PUT /ops/configtakes the nested shape and the other ops readers depend on the current contract.falseis the safe degrade direction on purpose:ssh_access_enableddefaults to"false"server-side, and a control that cannot read its own state must not claim the permissive one.Verification
Each side of the fix was mutation-checked rather than assumed:
Full frontend suite: 64 files / 1454 tests, green.
vite buildclean. Raw-color ratchet unaffected (no new colour usage).Closes #2411
🤖 Generated with Claude Code