Skip to content

feat: GSM Secrets - Save secret values through an optional store hook - #474

Open
yuechao-qin wants to merge 1 commit into
masterfrom
gsm-t1-store-hook
Open

yuechao-qin wants to merge 1 commit into
masterfrom
gsm-t1-store-hook

Conversation

@yuechao-qin

@yuechao-qin yuechao-qin commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

What

Secret values can now be kept outside the database: give setup_routes a secret_value_store, and creating or updating a secret saves the value through the store, keeping in the row only what the store returns and a note in extra_data saying where. Without a store, nothing changes.

Saving a secret, POST /api/secrets/?secret_name=TOKEN with {"secret_value": "s3cret"}, stores:

Column Before After, with a store
secret_value "s3cret" what save returned, e.g. ""
extra_data null {"storage": {"type": "<store type>", "details": {"version": "4"}}}
Operation With a store
create save puts the value in the store, then the row commits
update save puts the new value in the store, the row commits, then delete retires the value it replaced
delete the row is deleted and committed, then delete retires its value
retiring fails logged; the change stands, since it is already committed

A row whose storage names a store this server is not configured with is never changed: update and delete return 503, naming both stores, and leave the row as it was. Writing plain text over it, or deleting the row, would leave the stored value behind, still readable.

Why

Secret values sit in the database as plain text, so anyone who can read the table or a backup can read every secret. This adds the write half as a hook, so a deployment chooses the store (e.g. a cloud secret manager) and the backend stays free of any provider. Reading through the store at launch and moving existing rows follow in the next two PRs; until a deployment passes a store, behaviour is unchanged.

The value is saved before the row commits and the one it replaces is retired after, so no crash leaves a row naming a value that is gone. A crash between the two leaves an extra stored value, never a missing one.

Verification

  • New tests/test_secret_value_store.py, using a fake in-memory store: no store keeps plain text through create, update and delete; a store leaves only what save returned; update retires the previous value only once the committed row names the new one; delete retires after the row is gone; a plain row moves into the store on update; other extra_data keys survive; save and delete are refused, row unchanged, when the row is in another store or there is none; creating an existing name saves nothing; a failed retire is logged without the value; setup_routes passes the store through; a refusal is a 503.
  • Mutation-checked: retiring before commit, dropping either refusal, and not catching a failed retire each turn tests red.
  • Full suite: 655 passed, 22 failed — the same 22 in tests/instrumentation/test_execution_tracing.py fail on master.

@yuechao-qin
yuechao-qin requested a review from a team November 18, 2026 01:24
@yuechao-qin
yuechao-qin requested a review from Ark-kun as a code owner November 18, 2026 01:24
@yuechao-qin yuechao-qin changed the title gsm t1 store hook feat: GSM Secrets - Save secret values through an optional store hook Nov 18, 2026
value="hf_FAKE123")` returns `("", {"version": "4"})` — the row keeps `""`, and `{"version": "4"}`
is what `get` and `delete` are later given as `storage_details`.
"""
...
self, *, storage_details: dict[str, Any], user_id: str, secret_name: str
) -> str:
"""Returns the value that `save` saved with these storage details."""
...
self, *, storage_details: dict[str, Any], user_id: str, secret_name: str
) -> None:
"""Retires the value that `save` saved with these storage details."""
...
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.

2 participants