Restore a client config that was overwritten¶
Use this procedure when a client reports that a setting "changed by itself" or that values disappeared (starter questions, page-specific overrides, CTAs…). It finds who wrote the config and when, then puts back the last good version from the daily snapshots. For a knowledge FAQ, see Find who changed or disabled a knowledge FAQ.
config.client_configs holds the client's override only, one row per
(domain, config_slug, config_scope). A backoffice save replaces the whole row, so a
form saved with the wrong values loses everything that was not in it. Every night,
config.client_configs_daily_snapshots copies each row; see
Daily snapshot history.
Prerequisites¶
- Read access to the production Supabase project (Supabase MCP or SQL editor). Its
role is read-only on
config.client_configs: the write goes throughrose-config. backend/.env.productionfor therose-configwrite. Supabase is shared across environments, so every write in this procedure is a production write: get the operator's approval before step 4.- The slug is CLI-editable (
x-cli-editable: truein its schema). If it is not, stop and hand the diff to the operator.
Steps¶
1. Find the write¶
Read the current row and when it last changed:
SELECT enabled, config, updated_at
FROM config.client_configs
WHERE domain = 'acme.com' AND config_slug = 'engagement' AND config_scope = 'website';
Find who saved it in the Supabase logs (edge_logs, a window of a few minutes around
updated_at). Backoffice saves are POST upserts on client_configs?on_conflict=…;
the JWT subject is the user's auth.users.id:
SELECT timestamp, event_message,
log_attributes['request.sb.jwt.authorization.payload.subject'] AS user_id
FROM logs
WHERE source = 'edge_logs'
AND event_message ILIKE 'POST%client_configs?on_conflict%'
ORDER BY timestamp
SELECT u.email, b.display_name
FROM auth.users u LEFT JOIN public.backoffice_users b ON b.user_id = u.id
WHERE u.id = '<user_id>';
2. Pick the snapshot¶
Take the latest snapshot whose source_updated_at is before the bad write, and compare
it with the current row:
SELECT snapshot_date, source_updated_at, enabled, config
FROM config.client_configs_daily_snapshots
WHERE domain = 'acme.com' AND config_slug = 'engagement' AND config_scope = 'website'
ORDER BY snapshot_date DESC
LIMIT 3;
Restoring the snapshot undoes every save since it, not only the bad one. Run the step 1
log query from the snapshot's source_updated_at to now: if any other save touched the
row, or the bad save also held a legitimate change, list them for the operator and
re-apply the ones they keep after the restore.
3. Export the snapshot to a file¶
From backend/, with .env.production loaded (set -a; . ./.env.production; set +a):
.venv/bin/python - <<'EOF' > /tmp/restore.json
import json, os
from supabase import create_client
c = create_client(os.environ["SUPABASE_URL"], os.environ["SUPABASE_SERVICE_ROLE_KEY"])
rows = (c.schema("config").table("client_configs_daily_snapshots").select("config")
.eq("domain", "acme.com").eq("config_slug", "engagement")
.eq("config_scope", "website").eq("snapshot_date", "2026-10-08").execute().data)
assert len(rows) == 1, rows
print(json.dumps(rows[0]["config"], ensure_ascii=False, indent=2))
EOF
4. Write it back¶
Check that updated_at has not moved since step 1, then replace the whole override right
away. rose-config set is an unconditional upsert, so a save landing between the check
and the write would be lost: the verification below rules it out.
rose-config set engagement --site acme.com --env production -f /tmp/restore.json --dry-run
rose-config set engagement --site acme.com --env production -f /tmp/restore.json --yes
The snapshot is the override layer only, so writing it back does not bake in defaults.
If the snapshot's enabled is a boolean that differs from the row's, set it with
rose-config enable|disable <slug> --site <domain> --env production --yes. If the
snapshot's enabled is NULL (inherit the feature default) and the row's is not, stop
and ask the operator: the CLI only writes true or false.
Verification¶
The row matches the snapshot:
SELECT c.updated_at,
c.config = s.config AS config_matches,
c.enabled IS NOT DISTINCT FROM s.enabled AS enabled_matches
FROM config.client_configs c
JOIN config.client_configs_daily_snapshots s
ON s.domain = c.domain AND s.config_slug = c.config_slug
AND s.config_scope = c.config_scope AND s.snapshot_date = '2026-10-08'
WHERE c.domain = 'acme.com' AND c.config_slug = 'engagement';
Rerun the step 1 log query from the check in step 4 to now: your write is the only save.
Open the screen in the backoffice and wait about 15 seconds without touching anything: it shows the restored values and offers no Save. If Save appears on its own, the screen is rewriting the config; do not save, and file a bug.
Find who changed or disabled a knowledge FAQ¶
Use this section when a client's FAQ (config.knowledge_faqs, the chat retrieval
knowledge) was edited or disabled and you need to know who did it and when. Every
query is read-only; run them on the production Supabase project, which every
environment shares.
config.knowledge_faqs has no updated_by column, and updated_at only gives the
time of the last write. Every night, config.config_table_daily_snapshots copies each
FAQ row (source_table = 'knowledge_faqs', row_id = the FAQ's id, the full row in
row_data, its updated_at in source_updated_at), and keeps the newest 180 days.
The backoffice FAQ editor saves the Active/Disabled switch in the same form as the question and answer, so one save can both edit the text and disable the FAQ.
1. Find the day and the time of the save¶
List the FAQ's daily copies:
SELECT snapshot_date, captured_at, source_updated_at,
row_data->>'enabled' AS enabled,
row_data->>'last_processed_at' AS last_processed_at,
row_data->>'question' AS question,
row_data->>'answer' AS answer
FROM config.config_table_daily_snapshots
WHERE source_table = 'knowledge_faqs' AND row_id = '<faq id>'
ORDER BY snapshot_date;
The copy is taken at 02:20 UTC, so the first copy where enabled, question or
answer differs from the one before shows the change, made between the previous
copy's captured_at and this one's. Comparing both rows gives the text diff.
That copy's source_updated_at is the time of the save only if nothing else wrote the
row before the capture. Any update moves updated_at: another edit (topic, order) or
the knowledge sync stamping last_processed_at after it ingests the FAQ. If
last_processed_at is within a few seconds of source_updated_at, that time is the
sync's. When the time is not proven, search the whole interval between the two
captures in step 2.
2. Find who was signed in¶
If the save is less than a few days old, the Supabase edge_logs give the author: run
the step 1 log query with
event_message ILIKE 'PATCH%knowledge_faqs%' around the time of the save. Their
retention is short: two months later they are gone.
After that, auth.audit_log_entries shows which backoffice users had an active session
(token_refreshed, login) in the hour before the save (a backoffice session token
lasts an hour):
SELECT created_at,
payload->>'actor_username' AS user_email,
payload->>'action' AS action
FROM auth.audit_log_entries
WHERE created_at BETWEEN timestamptz '<source_updated_at>' - interval '1 hour'
AND timestamptz '<source_updated_at>' + interval '5 minutes'
ORDER BY created_at;
This gives a likely author, not proof: a signed-in user is not necessarily the one who
saved, and the Rose MCP also writes with its user's token. Report it as such. If no one
appears, report the author as unknown; a staff rose-config write, for one, uses the
service role and leaves no session.