Skip to content

fix(settings): persist only the billing delta so resolved secrets never hit disk#60

Merged
Aayam Bansal (aayambansal) merged 1 commit into
mainfrom
fix/spend-toggle-config-writeback
Jul 5, 2026
Merged

fix(settings): persist only the billing delta so resolved secrets never hit disk#60
Aayam Bansal (aayambansal) merged 1 commit into
mainfrom
fix/spend-toggle-config-writeback

Conversation

@aayambansal

Copy link
Copy Markdown
Member

Fixes #51.

The Spend toggle PUT handler round-tripped the entire resolved global config:

const cfg = await Config.getGlobal()
const next = { ...cfg, billing: { ...(cfg.billing ?? {}), ...patch } }
await Config.updateGlobal(next)

getGlobal() resolves {env:VAR} and {file:...} references, so flipping a toggle in Settings wrote the literal secrets into ~/.config/openscience/openscience.json and destroyed the env indirection.

updateGlobal already deep-merges into the raw on-disk file, so the route now passes only the delta:

await Config.updateGlobal({ billing: patch })

Added a regression test that drives the real route against an isolated config containing "apiKey": "{env:...}" and asserts the reference survives, the resolved value never hits disk, and only billing is written. It fails on main (the failure output shows the plaintext key in the file) and passes here.

Full backend suite: 829 pass / 0 fail. Typecheck clean.

…er hit disk

The Spend toggle PUT round-tripped Config.getGlobal() into
Config.updateGlobal(). getGlobal() returns the resolved config, with
{env:VAR} and {file:...} references substituted, so flipping a toggle
rewrote openscience.json with plaintext secrets and destroyed the env
indirection. updateGlobal already deep-merges into the raw file, so the
route only needs to pass the billing delta.
@vercel

vercel Bot commented Jul 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
openscience Ready Ready Preview, Comment Jul 5, 2026 10:56am

Request Review

@aayambansal Aayam Bansal (aayambansal) merged commit 4a0bd75 into main Jul 5, 2026
9 checks passed
@aayambansal Aayam Bansal (aayambansal) deleted the fix/spend-toggle-config-writeback branch July 5, 2026 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spend toggle rewrites openscience.json with resolved secrets in plaintext

1 participant