Skip to content

fix(backup): list no server-specific setting as lost on a replace - #5473

Open
rangoDJ wants to merge 4 commits into
Silo-Server:mainfrom
rangoDJ:fix/5249-replace-lost-settings
Open

rangoDJ wants to merge 4 commits into
Silo-Server:mainfrom
rangoDJ:fix/5249-replace-lost-settings

Conversation

@rangoDJ

@rangoDJ rangoDJ commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Depends on: none. Merge order: none. Follows #5199 (merged), which added the live server's own settings to this check.

Problem

Closes #5249
Related issue: #5199
Validation tasks: none

Other clients: none. silo backup restore output only.

When silo backup restore --accept-lost-credentials replaced the live database with a backup taken under another SECRET_KEY, the "cannot read" line still listed encrypted server-specific settings the live server doesn't have:

Cleared 3 encrypted settings this SECRET_KEY cannot read; enter them again after Silo starts: ai.providers, notifications.web_push.vapid_keypair, tmdb.api_key

The operator can't enter a web push key pair; Silo generates one on first use (WebPushService.vapidKeys). And the backup's value would never have survived anyway. CarryServerSpecificSettings gives the restored database the live server's server-specific settings and deletes the backup's ones the live server lacks. clearLostSettings (internal/backup/restore.go) left out only the ones the live server holds (liveOwn).

Approach

  • clearLostSettings takes whether the restore is a replace. On a replace it leaves out every setting carriedServerSpecific covers: those are the live server's value or none, whichever key the backup used. This takes in the liveOwn keys it already left out; liveOwn is still used for the outbound line.
  • A separate restore (restore --into) keeps the backup's server-specific settings and is unchanged.
  • This is the option the issue describes. One trade-off: on a replace onto a server without AI providers, ai.providers is no longer named. That matches a replace with the same key, which reports nothing for it either, since the carry deletes the backup's list. Units that still need re-entry are named by the outbound line ("enter them again to use them").

Validation

  • New test TestSwapListsNoServerSpecificSettingAsLost (swap_test.go): a replace onto a server with no server-specific settings, where the key can't read ai.providers, notifications.web_push.vapid_keypair and tmdb.api_key, lists only tmdb.api_key. On main it fails with all three listed; with this change it passes. The existing TestSwapReportsOnlyWhatTheRestoredServerLacks still passes.
  • go test ./internal/backup/ -run 'Swap|Restore|Lost|Carry': pass. go vet: clean. golangci-lint on the changed package (pre-commit): 0 issues.
  • Real Postgres, added in review: a full replace (RestoreSwap through PGLoader) of a backup taken under one key, holding encrypted ai.providers, the web push key pair and tmdb.api_key, onto a live database under another key that has none of them. Base prints Cleared 3 ... ai.providers, notifications.web_push.vapid_keypair, tmdb.api_key. This branch prints Cleared 1 ... tmdb.api_key. In both, the restored database holds none of the three. That scratch test was not committed.
  • docs/architecture/backups.md now states the new rule (review commit).
  • Not tested: a restore between two running deployments.

Evidence

Evidence: not needed. No visible change in the apps; the change is a line of silo backup restore output, shown by the test.

On main (0a631fb), with the new test:

--- FAIL: TestSwapListsNoServerSpecificSettingAsLost (0.00s)
    swap_test.go:943: output lists more than the TMDB key to enter again:
        ...
        Cleared 3 encrypted settings this SECRET_KEY cannot read; enter them again after Silo starts: ai.providers, notifications.web_push.vapid_keypair, tmdb.api_key

With this PR the line reads Cleared 1 encrypted settings this SECRET_KEY cannot read; enter them again after Silo starts: tmdb.api_key, and:

ok  	github.com/Silo-Server/silo-server/internal/backup	0.956s

Risks

  • An operator replacing onto a server without AI providers no longer sees ai.providers named in this line. The restored server has none either way, as described above.
  • No API, schema or config change.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
  • The Evidence section shows every change a user can see, or how I checked a change nobody sees.

AI Disclosure

  • Harness: Claude Code in the Claude desktop app
  • Tool(s): Claude Code
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated, not yet human verified
  • Adversarial review: n/a

🤖 Generated with Claude Code

Note

Omit server-specific settings from replace-restore lost list

  • During a replace restore, server-specific settings the backup key cannot read are no longer listed as lost. clearLostSettings in restore.go now takes a replace flag and filters these keys via carriedServerSpecific. The restored database gets the live server's value, or no value if the live server has none.
  • Swap restores pass true for this flag in swap.go; separate restores pass false and still list unreadable settings for re-entry.
  • Adds a regression test TestSwapListsNoServerSpecificSettingAsLost and updates the backup architecture doc in backups.md.
  • Behavioral Change: only replace (swap) restores change their report. Separate restores are unchanged; see the false argument in RestoreSeparate in restore.go.

Macroscope summarized 58ac1cf.

When silo backup restore --accept-lost-credentials replaced the live
database with a backup taken under another SECRET_KEY, the "enter them
again" line still listed encrypted server-specific settings the live
server doesn't have, such as notifications.web_push.vapid_keypair on a
server that never used web push. The operator can't enter that, Silo
generates it on first use, and the backup's value would never have
survived: CarryServerSpecificSettings gives the restored database the
live server's server-specific settings and deletes the backup's others.

On a replace, clearLostSettings now leaves out every setting
carriedServerSpecific covers, which takes in the live server's own
settings it already left out. A separate restore is unchanged.

Closes Silo-Server#5249

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@silo-triage silo-triage Bot added the size/S 0–49 added + deleted lines (all files); change volume, not priority. label Nov 27, 2026
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Replacement restores now exclude carried server-specific settings from the list of unreadable credentials that operators must re-enter. Separate restores do not apply this filtering. A test checks the reported settings for an accepted backup from another deployment.

Changes: Restore credential reporting

Layer / File(s) Summary
Filter lost-setting reports for replacement restores
internal/backup/restore.go, internal/backup/swap.go, internal/backup/swap_test.go
clearLostSettings now receives a replacement flag. Replacement restores exclude keys covered by carriedServerSpecific from the re-entry list; separate restores do not. The added test checks that only tmdb.api_key is listed for re-entry in the described restore case.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related PRs

Suggested reviewers: rhainland, quick104

Merge Risk: Minimal · up to c2fe6

Replace restores will stop listing settings the live server supplies or removes, so operators are asked to re-enter only the credentials they actually lack. Separate restores are unchanged, and a test covers the changed output. No merge-blocking risk remains.

Security architecture risk: Minimal · up to c2fe6

Replacement restores no longer ask operators to re-enter credentials that the backup would not supply in a successful restore. The change affects the instructions, not which credentials are cleared or retained. Separate restores report as before.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed behavior is confined to the operator’s output for a replacement restore that enters the existing lost-credentials path. The filter adds no destination or credential consumer and writes setting names, not values.

Trust Boundaries and Controls

  • observed — The credentials-loss acceptance gate is unchanged. In replacement restores, the existing carry transaction uses the live database as the source of server-specific values and removes restored entries for keys absent from that source.
Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: on a replace restore, the backup/restore report no longer lists server-specific settings as lost. It follows the conventional fix(backup) form and matches the summary,…
Linked Issues check Passed [#5249] Requirement: on a replace, the "cannot read" line must omit server-specific settings that CarryServerSpecificSettings covers (the live server supplies them or they are removed). The PR changes…
Out of Scope Changes check Passed The changed areas, as described in the PR summary, are internal/backup/restore.go (clearLostSettings signature, replace-mode exclusion, postLoad.liveOwn comment), internal/backup/swap.go (RestoreSwap …
Description check Passed The description is specific and on-topic. It names the silo backup restore --accept-lost-credentials output, the clearLostSettings change in internal/backup/restore.go, the `carriedServerSpecifi…
Full details: Title check

Explanation

The title names the main change: on a replace restore, the backup/restore report no longer lists server-specific settings as lost. It follows the conventional fix(backup) form and matches the summary, the linked issue #5249, and the test added. Some terms are specific, but a teammate scanning history would understand the primary change.

Full details: Linked Issues check

Explanation

[#5249] Requirement: on a replace, the "cannot read" line must omit server-specific settings that CarryServerSpecificSettings covers (the live server supplies them or they are removed). The PR changes clearLostSettings to take a replace flag. On a replace it excludes every key recognized by carriedServerSpecific, so ai.providers, notifications.web_push.vapid_keypair and tmdb.api_key are not all listed. RestoreSwap passes true. The new test TestSwapListsNoServerSpecificSettingAsLost asserts that only tmdb.api_key is listed. The author reports it fails on base 0a631fb and passes at head. The reviewer confirmed the same. A separate restore keeps its previous behavior (passes false), which matches the issue. The issue's expected behavior names the outbound line as the place for units that still need re-entry, and the PR keeps that line. Limits: the repository diff could not be read (changed blobs unavailable), so this verdict rests on the PR summary, the AI-generated change summary and the author-reported test results. The live cross-deployment restore was not tested, which the issue also does not require.

Full details: Out of Scope Changes check

Explanation

The changed areas, as described in the PR summary, are internal/backup/restore.go (clearLostSettings signature, replace-mode exclusion, postLoad.liveOwn comment), internal/backup/swap.go (RestoreSwap passes true, comment updates) and internal/backup/swap_test.go (one new test). All of them serve the #5249 fix, either by changing the report or by documenting it and testing it. No unrelated behavior, API, schema or config change is described. The reviewer's note about the restore manual is a documentation follow-up. It is not part of the diff, so it is not an out-of-scope change. The diff itself could not be read, so this verdict relies on the PR summary.

Full details: Description check

Explanation

The description is specific and on-topic. It names the silo backup restore --accept-lost-credentials output, the clearLostSettings change in internal/backup/restore.go, the carriedServerSpecific filter, the new test TestSwapListsNoServerSpecificSettingAsLost, and the validation steps. It also lists the trade-off for ai.providers and the risks. This clearly relates to the changeset, so the check passes.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8460a3ac-6a13-40a5-8456-5a9a9d1a9c78
Commits

Reviewing files that changed from the base of the PR and between 0a631fb and c2fe6f0.

Files selected for processing: 3

  • internal/backup/restore.go
  • internal/backup/swap.go
  • internal/backup/swap_test.go

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@silo-triage silo-triage Bot added bug Something isn't working go Pull requests that update go code impact: polish Annoyance, cosmetic, or nice-to-have priority: P2 Limited scope, workaround exists, or polish labels Nov 27, 2026

@Quick104 Quick104 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of 3eab901. The change is correct; one trade-off is left for the maintainers (inline) and one comment nit.

Nit, not on a changed line: the comments on postLoad.liveOwn (internal/backup/restore.go, around line 313) and above the ServerSpecificSettingKeys call in swap.go (around line 186) still describe liveOwn as what keeps settings out of the lost list. The lost-settings pass no longer reads it. It now only decides which cleared outbound units are reported as kept.

🤖 Claude Code (claude-opus-5-5)

}
keys = slices.DeleteFunc(keys, func(k string) bool { return slices.Contains(liveOwn, k) })
if replace {
keys = slices.DeleteFunc(keys, carriedServerSpecific)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maintainer decision (low): AI providers that no job uses. The PR relies on the outbound line ("... enter them again to use them: AI providers") to cover ai.providers. That line fires only when some AI setting survives ClearUnreadableSettings, usually a plaintext job binding. A provider that was connected but never selected for a job (the create endpoint says "Nothing uses it until a job selects it") lives only in ai.providers.

Trigger: a replace with another SECRET_KEY onto a server without AI providers, from a backup whose providers no job uses. ClearUnreadableSettings deletes the registry before CarryOutboundSettings checks for surviving secrets, so the AI unit isn't reported there, and this filter now drops ai.providers from the cannot-read line.

Impact: neither line mentions the backup's AI providers. The restored server loses them either way, since the carry gives it the live server's (empty) registry. Only the hint is gone, and only for a provider no job used.

Options: accept it, as #5249 weighed; or, in a follow-up, have the outbound report also name a unit whose secrets the unreadable-settings pass cleared. Left for the maintainers; no change needed from the author.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Author's view, for whoever decides: I'd accept it for this PR. The restored server loses those providers either way, and only the hint is missing, only for a provider no job used. Naming a unit whose secrets the unreadable-settings pass cleared fits better as its own change to the outbound report. I can open that follow-up if you want it.

@Quick104

Quick104 commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Review of 58ac1cf (earlier: 3eab901)

The fix is correct and does what the PR says. On a replace, every key carriedServerSpecific covers ends up as the live server's value or as nothing, because carryLiveState always runs carryServerSpecificSettings after clearLostSettings, before the swap's journal exists. So none of those keys belongs in the "enter them again" line. RestoreSeparate behaves as before.

Since the last review I merged main into the branch, because main's #5475 changed the outbound report this PR relies on for AI providers. #5475 narrows the open trade-off below: when the backup leaves a legacy AI endpoint behind, the outbound line now names "AI providers". I also fixed the backups architecture doc and one test comment that still described the old rule (58ac1cf).

Verification

  • TestSwapListsNoServerSpecificSettingAsLost fails on current main (8fcf75f) with all three keys listed and passes on this branch. go test ./internal/backup/ and lint-changed pass.
  • A full replace on real Postgres: RestoreSwap through PGLoader, with a backup taken under one key holding encrypted ai.providers, the web push key pair and tmdb.api_key, restored onto a live database under another key that has none of them. Main prints Cleared 3 ... ai.providers, notifications.web_push.vapid_keypair, tmdb.api_key; this branch prints Cleared 1 ... tmdb.api_key. In both runs the restored database holds none of the three, so the shorter line matches what the restored server has. This was a scratch test, not committed. No restore between two running deployments was done.

Addressed

  • Doc drift: docs/architecture/backups.md and the comment on TestSwapReportsOnlyWhatTheRestoredServerLacks now state the new rule (58ac1cf).
  • The comment nit from the last review was fixed by the author in c2fe6f0.

Remaining for the maintainers

  • Maintainer decision: credentials no other line names. A provider connected but never selected for a job lives only in ai.providers. On a cross-key replace onto a server without AI providers, neither line names it now. ChatGPT credentials, the push relay key, and the search engine key drop out the same way. In each case the restored server ends up with this server's setup (or none), so there's nothing to enter again; only the hint that the backup had one is gone. The author would accept it for this PR. The options are to accept it as [bug] A replace with another key asks to re-enter server-specific settings the live server never had #5249 weighed, or to follow up by having the outbound report name a unit whose secrets the unreadable-settings pass cleared.
  • A separate restore (restore --into) still asks to re-enter the web push key pair. That predates this PR, and fixing it changes the same lines, so it's filed as [bug] A separate restore with another key asks to re-enter the web push key pair #5675 to follow this one.
  • Found during review, not caused by this PR: on a cross-key replace onto a live database with no ai.providers row (one that has never started), the AI providers reset from fix(backup): reset the AI providers when a restore leaves only legacy endpoints #5475 doesn't stick. The outbound line says AI providers were turned off, then the server-specific carry deletes the empty registry the reset wrote. The backup's ai.base_url survives, so the next start builds a provider from it. A run on main showed this. It needs its own fix in the carry or outbound code.

Validated features: no passed case on the v1.0 board touches backup or restore. Validation tasks: none is correct.

User manual: the restore page's "If the backup came from another server or key" section says the command lists cleared settings "such as storage, plugin, or email server credentials". A full restore never lists storage credentials, which are this server's own. A siloserver.org issue should adjust that example on running-a-server/restore.md; none exists yet.

Other clients: none. The change is silo backup restore output only. No jellycompat or API surface.

Council

Member Round 1 (3eab901) Round 2 (eb9f6ef)
Sol (gpt-6.2-sol, medium) 8/10 8/10
Opus (claude-opus-5-5, medium) 8.5/10 8.5/10
Gemini (gemini-4-neon, medium) 6/10 8/10

In round 2, Gemini flagged the doc drift, fixed in 58ac1cf, and the separate-restore case, filed as #5675. Sol and Gemini both found the AI reset problem described above, and a run on main confirmed it predates this PR. Opus found nothing blocking: it called the ChatGPT, push relay and search keys part of the same trade-off, and noted a redundant f.ctl.liveOwn = nil in the new test, which is harmless. All three confirmed that the recover path, older-schema skips, and errors after the clear can't leave a key deleted, uncarried and unreported. The round 2 head differs from this one only in docs and a test comment.

Fit: 9/10 · Readiness: 8/10 — conditional (one maintainer decision)

  • Fit: a small correctness fix to restore output, at the boundary that owns it, with no new surface.
  • Readiness: the approach is sound, the new test fails on main, and the real-Postgres replace shows the corrected line. It isn't 9 because the credentials trade-off above needs a maintainer's call.

🤖 Claude Code (claude-opus-5-5)

The lost-settings pass no longer reads liveOwn. It only decides which
cleared outbound units are reported as kept (review on Silo-Server#5473).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@silo-triage silo-triage Bot added size/M 50–199 added + deleted lines (all files); change volume, not priority. and removed size/S 0–49 added + deleted lines (all files); change volume, not priority. labels Nov 29, 2026
@rangoDJ

rangoDJ commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

The comment nit is fixed in c2fe6f0. The comments on postLoad.liveOwn in restore.go and above the ServerSpecificSettingKeys call in swap.go now say it decides which cleared outbound units are reported as kept, not what is kept out of the lost list. No code change. go test ./internal/backup/ and lint-changed pass.

Quick104 and others added 2 commits November 30, 2026 15:24
The backups architecture doc and the comment on
TestSwapReportsOnlyWhatTheRestoredServerLacks still described the old rule,
where only the settings the live server supplies stayed off the list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@silo-kody

silo-kody Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌
⚠️ 4 Kody Rule(s) were not evaluated

These rules declare that they need repository context beyond this diff, and the review could not retrieve it, so they were not judged on this pull request:

  • Preserve optional store capabilities through production wrappers
  • Detach mandatory cleanup from request cancellation and bound its lifetime
  • Preserve durable media identity and share identity-evidence precedence
  • Bound decoder throughput trades and share direct-play eligibility

@Quick104 Quick104 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of eb9f6ef (c2fe6f0 with main merged in). The code change is still correct. Two findings, both fixed or tracked; details below and in the summary comment.

  1. Doc drift (low, fixed in 58ac1cf). docs/architecture/backups.md still said a replace leaves off the lost list only the server-specific settings the live server supplies (ServerSpecificSettingKeys). After this PR it leaves off every one carriedServerSpecific matches, and ServerSpecificSettingKeys only decides which cleared outbound units are reported as kept. The comment on TestSwapReportsOnlyWhatTheRestoredServerLacks said the same. I fixed both in a commit on this branch, so there's no need to change them yourself.
  2. Separate restore still lists the web push key pair (low, predates this PR). restore --into passes replace=false, so a cross-key separate restore still says to enter notifications.web_push.vapid_keypair again, which Silo generates on first use. The fix would change the lines this PR changes, so it's filed as #5675 to follow this PR. Nothing to change here.

🤖 Claude Code (claude-opus-5-5)

Comment thread docs/architecture/backups.md Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update go code impact: polish Annoyance, cosmetic, or nice-to-have priority: P2 Limited scope, workaround exists, or polish size/M 50–199 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] A replace with another key asks to re-enter server-specific settings the live server never had

2 participants