You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(backup): keep settings the environment sets out of a selective restore - #4667
Related issue: N/A
Validation tasks: none
Other clients: N/A (no client-visible change: Apple, Android, and Roku have no backup restore screens; the web restore flow is updated here)
On a server that sets some settings from environment variables, a selective restore failed whole settings pages. A restore writes every differing setting of a page in one admin settings batch, and that write path refuses any key the environment sets (managed_by_environment). One such key, for example branding.server_name from SILO_SERVER_NAME or email.smtp_password from SILO_SMTP_PASSWORD, made the restore report the page as failed, and none of the page's other settings were restored. The preview gave no warning: it offered the page as differing and selectable.
With this change, a restore leaves out what the environment sets, shows those settings as kept, and restores the rest of the page.
Approach
The restore asks the admin handler which settings the environment sets (AdminHandler.EnvironmentSetting, the same lookup the save refusal uses) and compares the backup with the environment's value. A difference gets the new setting status managed_by_environment and is never written. A page whose only differences are of that kind can't be chosen, with the new reason managed_by_environment.
If the environment sets any setting of an outside-service connection, every setting of that connection keeps its current value. The connections are the units the full restore already carries whole (outboundBundles): the SMTP host, port, security, username, password, sender, and switch together, and likewise for the other outside services. Otherwise a restore could pair the environment's settings with the backup's. For example, SILO_SMTP_SECURITY=none would have sent the backup's password to the backup's host in plain text.
/api/v2 gains the enum value managed_by_environment on the restore preview's setting status and on the preview and report reason. The web restore flow shows the kept value as "(kept: environment)", adds a Left out line in the review, and adds a heading for pages that can't be restored. The wording comes from feat(catalog): add the restore wording for settings the environment sets silo-translations#114, which is merged and pinned here.
docs/backups-api.md and docs/architecture/backups.md describe the new status.
Validation
Live, on a dev sandbox with SILO_SERVER_NAME and SILO_SMTP_PASSWORD set, against a backup whose server name, login subtitle, SMTP host, password, and sender name differ:
Unfixed build (88b825d5): the General and Email pages were offered as differing. Restoring them reported "Restored nothing, 2 failed", and the subtitle and sender name stayed unrestored.
Fixed build (47f89499, this change before its rebase onto current main): restoring General brought back the subtitle and kept the environment's server name. Email showed the whole SMTP connection as kept and couldn't be chosen. Restoring General a second time left it out with managed_by_environment.
Go: the new Postgres test (preview, partial restore, the all-environment page, and the kept SMTP connection) and a unit table for the connection rule pass, along with the existing route-guard and settings-restore DB tests. The new tests use the new restore hook, so they don't build on main. As a stand-in, the Postgres test failed the way the sandbox did when the planner was blinded to the environment.
Gate: make lint-changed, go build and go vet ./... on Linux, focused internal/backup, internal/api, and internal/api/handlers tests, web typecheck, lint, and format check, verify-apiv2-openapi, verify-apiv2-web-types, verify-apiv2-fixtures, verify-route-inventory, verify-local-paths, and verify-size-ratchet pass. verify-apiv2-contract passes with the approvals in this PR. The full make test-go was left to CI. In the web suite, 29 tests in four player and API-client files fail on this machine, and they fail the same way on main; every other web test passes.
Response enums gain one value; the pre-1.0 contract gate lists them in breaking-approvals.json. Only the web app reads these schemas.
Each API server plans the restore with its own environment. Stored-scope variables must already match across API servers. A process-scope variable (SILO_SCANNER_WORKERS, SILO_MATCHER_WORKERS) can differ between servers, so whether the stored row is restored depends on which server runs the job, as with an admin save on that server.
Follow-ups:
Pre-existing, found in the visual review: the web dark: variant follows the operating system's color scheme instead of Silo's theme, so warning text such as the restore page's amber messages changes color on a theme that didn't (follow-up run started).
Fixed: the Restart badge now shows only on rows a restore writes (Sol S3, then Kody's note about cleared rows). Answered: a process-scope variable set on only some API servers (Sol S1). Fixed: a held mail connection's switch and transport are labeled managed_by_environment too, so the Email page names the environment (Gemini G1). Filed: English restore explanations and pages mixing kept-back reasons, which predate this change (Sol S2, Gemini G2, #4669).
Visual review: 1 round, captures from 47f89499
Member
Round 1
Sol
better, 7/10
Opus
better, 7/10
Gemini
better, 6.5/10
Answered: the repeated reason under the can't-be-restored heading and the kept rows' emphasis follow the existing pattern every blocked reason shares; the light-theme color mismatch predates this change and has its own follow-up.
AI Disclosure
Harness: Claude Code in T3 Code
Tool(s): Claude Code subagents (code-review finders and sweep), T3 Code delegate_task (plan, visual, and background reviews), Codex CLI and Antigravity for the Sol and Gemini reviewers
Model(s): claude-opus-5-5 (implementation, plan and visual reviewer), claude-sonnet-5-5 (one code-review finder), gpt-6.2-sol, gemini-4-neon
Involvement: Fully AI-generated (agent-verified on a dev sandbox; human review pending)
Adversarial review: A plan round (Sol, Opus, Gemini) changed the mail handling to one connection rule and the comparison to the environment's value. An xhigh code review (three finders and a sweep) moved the rule to the full restore's outbound bundles after it found the plain-text transport case, shared the environment lookup with the save refusal, and added the all-environment page test. A simplify pass ran. See Council review.
Exclude environment-managed settings from selective backup restore
Selective restore now treats settings configured via environment variables as read-only: previews compare against the environment value, mark them with a new managed_by_environment status, and leave them out of the restore (selective_settings.go).
If the environment sets any setting in an outbound-service bundle (e.g. an SMTP connection), the whole bundle is kept together via keepEnvironmentBundles.
RestoreTargets gains an optional EnvironmentValue callback, wired from AdminHandler.EnvironmentSetting (admin.go, backup_restore_wiring.go).
UI and API surfaces add the new status and reason: restore rows, blocked-title labels, caveats, OpenAPI/TypeScript enums, and docs.
Risk: behavioral change — settings the environment sets are no longer restorable; check planSettings, applySettingsPage, and the managed_by_environment enum additions in admin_backup_restore.go and schema.ts. Restore-setting rows now show the restart badge only for differs and cleared statuses.
Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 269def3c-91f5-42ca-bb6e-5f72c39fdece
Commits
Reviewing files that changed from the base of the PR and between 34137b3 and b6f8eb9.
Files selected for processing: 17
contracts/api/v2/breaking-approvals.json
contracts/api/v2/openapi.json
docs/architecture/backups.md
docs/backups-api.md
internal/api/backup_restore_wiring.go
internal/api/handlers/admin.go
internal/apiv2/admin_backup_restore.go
internal/backup/selective.go
internal/backup/selective_postgres_test.go
internal/backup/selective_settings.go
internal/backup/selective_settings_routes.go
internal/backup/selective_settings_routes_test.go
scripts/ci/db-contracts.txt
web/src/api/v2/schema.ts
web/src/pages/admin-backups/RestoreRows.tsx
web/src/pages/admin-backups/restoreGroups.ts
web/src/pages/admin-backups/restoreModel.ts
Walkthrough
Selective restore now detects settings controlled by the restore server’s environment. It preserves those values, reports a managed_by_environment status and reason, and displays the affected settings and caveats in the web interface.
Changes: Environment-managed restore settings
Layer / File(s)
Summary
Restore status contract and environment lookup contracts/api/v2/openapi.json, internal/apiv2/admin_backup_restore.go, internal/backup/selective.go, internal/api/handlers/admin.go, internal/api/backup_restore_wiring.go, contracts/api/v2/breaking-approvals.json
The restore contract adds the managed_by_environment status and reason. RestoreTargets gains an environment-value callback, which the admin handler provides. The API contract records the enum changes and approvals.
Restore planning compares backup values with environment values and marks affected settings and outbound connection bundles as managed. Previews and restore results report the status, and page notes count affected settings. Tests and documentation cover the behavior.
Web display and localized messages web/src/api/v2/schema.ts, web/src/pages/admin-backups/*, web/src/locales/keys.ts, web/src/locales/*.json, .silo-translations
The web client recognizes the new status and reason, displays managed values and restore caveats, and adds translated messages across the supported locales. The translation catalog version and checksum are updated.
sequenceDiagram
participant RestoreWiring
participant EnvironmentSetting
participant RestorePlanner
participant RestoreAPI
participant RestoreUI
RestoreWiring->>RestorePlanner: provide environment-value callback
RestorePlanner->>EnvironmentSetting: look up configured setting
EnvironmentSetting-->>RestorePlanner: return value and presence
RestorePlanner->>RestoreAPI: provide managed status and reason
RestoreAPI->>RestoreUI: return restore details for display
Loading
Merge Risk: Low · previous review 34137
Selective restore now keeps environment-managed settings and reports them through the API and web UI. No functional defect was found. Before merging, add a test case where the stored, environment, and backup values all differ, so the environment-value override is protected.
Security architecture risk: Minimal · up to 34137
The inspected change preserves environment-controlled settings and prevents restored credentials from being combined with incompatible connection settings. No introduced or worsened security, ownership, or failure-containment issue was established.
Retained concerns
No architecture-level concerns identified.
Security review details
Security Blast Radius
inferred — The relevant security scope is server-wide settings and the external services that consume restored configuration. The change limits restoration authority over environment-owned values and their connection bundles rather than granting additional credential or infrastructure authority.
Trust Boundaries and Controls
observed — Backup-provided external-service configuration remains blocked when the backup is unauthenticated, and unreadable encrypted values remain non-writable. For readable settings, environment ownership prevents an incoming backup from replacing either the managed key or other differing members of its outbound connection bundle.
Resilience and Maintainability Implications
observed — Repeated application re-evaluates live settings instead of trusting the original preview. A concurrent route or access-policy change detected by the settings guard causes rollback and bounded retry, avoiding use of stale security-sensitive comparisons.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: settings the server environment manages are excluded from a selective backup restore, so one such setting no longer fails the whole settings page. The changeset matche…
Description check
The description states the problem (a selective restore failed whole settings pages when the environment sets some settings), the approach (new managed_by_environment status, EnvironmentSetting lookup…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: settings the server environment manages are excluded from a selective backup restore, so one such setting no longer fails the whole settings page. The changeset matches this, including the restore planner, the new managed_by_environment status, and the web restore flow. The prefix fix(backup) follows the conventional-commit style.
Full details: Description check
Explanation
The description states the problem (a selective restore failed whole settings pages when the environment sets some settings), the approach (new managed_by_environment status, EnvironmentSetting lookup, connection-level keep rule, API and web changes, docs), validation, and risks. These match the changed files, so the description is clearly related to the changeset.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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 settingsReview Options
The following review options are enabled or disabled:
Options
Enabled
Bug
✅
Performance
✅
Security
✅
Business Logic
❌
⚠️ 5 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
Retain distributed firing claims through their own validity windows
Checked every restorable environment-settable key, all callers of the changed functions, docs (docs/backups-api.md, docs/architecture/backups.md), API v2 enums, OpenAPI generation, breaking-approvals.json, web types/maps, and the .silo-translations release pin. Core write-path safety, bundle holding, OpenAPI/breaking-approval parity (14/14 exact matches), and the published v2026.11.20-bf5a701 translation bundle all verify cleanly.
Two findings posted inline:
G1 (medium):keepEnvironmentBundles skips SettingKeptStricter bundle members (email.enabled, email.smtp_security), mislabeling the Email page as kept_stricter in the common case where the backup has email.enabled = true and the target sets SILO_SMTP_PASSWORD or SILO_SMTP_HOST with email disabled.
G2 (low): When a page has no writable settings and mixes managed_by_environment with another hold-back status (kept_stricter, needs_another_key, unverified_backup), settingsPageItems and applySettingsPage emit an unqualified single-reason message and drop the environment note.
AI-assisted review: gemini-4-neon (Antigravity / T3 Code).
Cover stored, environment, and backup values that differ.
The new test writes the environment value to the database before preview. The current-value override in planSettings is therefore not needed to pass the status assertions. Removing it leaves this test green.
Add a case where the stored value differs from the environment value. Assert these outcomes:
Backup "Backup Name", environment "Env Name", stored "Stored Name": the status is managed_by_environment, and the preview CurrentValue is "Env Name".
Backup "Env Name", environment "Env Name", stored "Stored Name": the status is on_this_server.
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: 16f43664-a979-4814-85c1-319fd39610a7
Commits
Reviewing files that changed from the base of the PR and between 66b836f and 34137b3.
Files selected for processing: 60
.silo-translations
contracts/api/v2/breaking-approvals.json
contracts/api/v2/openapi.json
docs/architecture/backups.md
docs/backups-api.md
internal/api/backup_restore_wiring.go
internal/api/handlers/admin.go
internal/apiv2/admin_backup_restore.go
internal/backup/selective.go
internal/backup/selective_postgres_test.go
internal/backup/selective_settings.go
internal/backup/selective_settings_routes.go
internal/backup/selective_settings_routes_test.go
scripts/ci/db-contracts.txt
web/src/api/v2/schema.ts
web/src/locales/ar-XB.json
web/src/locales/ar.json
web/src/locales/bg.json
web/src/locales/ca.json
web/src/locales/cs.json
web/src/locales/da.json
web/src/locales/de.json
web/src/locales/el.json
web/src/locales/en-XA.json
web/src/locales/en.json
web/src/locales/es.json
web/src/locales/et.json
web/src/locales/fi.json
web/src/locales/fr.json
web/src/locales/he.json
web/src/locales/hi.json
web/src/locales/hr.json
web/src/locales/hu.json
web/src/locales/id.json
web/src/locales/it.json
web/src/locales/ja.json
web/src/locales/keys.ts
web/src/locales/ko.json
web/src/locales/lt.json
web/src/locales/lv.json
web/src/locales/ms.json
web/src/locales/nb.json
web/src/locales/nl.json
web/src/locales/pl.json
web/src/locales/pt-BR.json
web/src/locales/pt-PT.json
web/src/locales/ro.json
web/src/locales/ru.json
web/src/locales/sk.json
web/src/locales/sl.json
web/src/locales/sv.json
web/src/locales/th.json
web/src/locales/tr.json
web/src/locales/uk.json
web/src/locales/vi.json
web/src/locales/zh-Hans.json
web/src/locales/zh-Hant.json
web/src/pages/admin-backups/RestoreRows.tsx
web/src/pages/admin-backups/restoreGroups.ts
web/src/pages/admin-backups/restoreModel.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
On the CodeRabbit nitpick about covering a stored value that differs from the environment's: not adding that case. For a stored-scope variable, startup writes the environment's value into the row, so the two can't differ. They differ only for the process-scope scanner.workers and matcher.workers. There the override decides what the preview shows as the current value and whether the row reads as the same or as kept; neither key is written in either case. What the restore must never do, write a setting the environment sets, is what TestRestoreLeavesOutSettingsTheEnvironmentSetsDB checks, so a test of the display alone doesn't meet "Decide what to test" in CONTRIBUTING.md.
…store
A selective restore wrote every differing setting of a page in one admin
settings batch. When the server's environment set one of them (for
example SILO_SERVER_NAME or SILO_SMTP_PASSWORD), the write path refused
the whole batch with managed_by_environment, the page failed, and none
of its other settings were restored.
The restore now compares the backup with the value the environment sets
and marks a difference managed_by_environment instead of writing it; the
rest of the page restores. An outside-service connection the environment
sets any setting of (the outbound bundles the full restore already
carries as units, such as mail's SMTP settings) keeps every setting as it
is, so a restore never pairs the environment's SMTP transport, host, or
password with the backup's.
The admin handler's EnvironmentSetting is the one lookup both the write
path's refusal and the restore read. The web restore flow shows the new
status, page reason, blocked heading, and review caveat.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A row the restore keeps (set by the environment, kept stricter, or
otherwise left out) showed "Restart" when its key needs one, though
nothing would change.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A cleared setting is written too (settingPlan.writes), so a
restart-required one still needs its badge.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
When the environment sets part of the SMTP connection, email's switch or
transport could stay kept_stricter while the rest of the connection was
managed_by_environment, so the Email page blamed widened access instead
of the environment.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bugSomething isn't workingimpact: usabilityCore flow broken or severely blockedpriority: P2Limited scope, workaround exists, or polishsize/L200–499 added + deleted lines (all files); change volume, not priority.
1 participant
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Related issue: N/A
Validation tasks: none
Other clients: N/A (no client-visible change: Apple, Android, and Roku have no backup restore screens; the web restore flow is updated here)
On a server that sets some settings from environment variables, a selective restore failed whole settings pages. A restore writes every differing setting of a page in one admin settings batch, and that write path refuses any key the environment sets (
managed_by_environment). One such key, for examplebranding.server_namefromSILO_SERVER_NAMEoremail.smtp_passwordfromSILO_SMTP_PASSWORD, made the restore report the page as failed, and none of the page's other settings were restored. The preview gave no warning: it offered the page as differing and selectable.With this change, a restore leaves out what the environment sets, shows those settings as kept, and restores the rest of the page.
Approach
AdminHandler.EnvironmentSetting, the same lookup the save refusal uses) and compares the backup with the environment's value. A difference gets the new setting statusmanaged_by_environmentand is never written. A page whose only differences are of that kind can't be chosen, with the new reasonmanaged_by_environment.outboundBundles): the SMTP host, port, security, username, password, sender, and switch together, and likewise for the other outside services. Otherwise a restore could pair the environment's settings with the backup's. For example,SILO_SMTP_SECURITY=nonewould have sent the backup's password to the backup's host in plain text./api/v2gains the enum valuemanaged_by_environmenton the restore preview's settingstatusand on the preview and reportreason. The web restore flow shows the kept value as "(kept: environment)", adds a Left out line in the review, and adds a heading for pages that can't be restored. The wording comes from feat(catalog): add the restore wording for settings the environment sets silo-translations#114, which is merged and pinned here.docs/backups-api.mdanddocs/architecture/backups.mddescribe the new status.Validation
SILO_SERVER_NAMEandSILO_SMTP_PASSWORDset, against a backup whose server name, login subtitle, SMTP host, password, and sender name differ:88b825d5): the General and Email pages were offered as differing. Restoring them reported "Restored nothing, 2 failed", and the subtitle and sender name stayed unrestored.47f89499, this change before its rebase onto currentmain): restoring General brought back the subtitle and kept the environment's server name. Email showed the whole SMTP connection as kept and couldn't be chosen. Restoring General a second time left it out withmanaged_by_environment.main. As a stand-in, the Postgres test failed the way the sandbox did when the planner was blinded to the environment.make lint-changed,go buildandgo vet ./...on Linux, focusedinternal/backup,internal/api, andinternal/api/handlerstests, web typecheck, lint, and format check,verify-apiv2-openapi,verify-apiv2-web-types,verify-apiv2-fixtures,verify-route-inventory,verify-local-paths, andverify-size-ratchetpass.verify-apiv2-contractpasses with the approvals in this PR. The fullmake test-gowas left to CI. In the web suite, 29 tests in four player and API-client files fail on this machine, and they fail the same way onmain; every other web test passes.Evidence: https://evidence.siloserver.org/r/silo-server/restore-env-managed-settings/
Risks
breaking-approvals.json. Only the web app reads these schemas.SILO_SCANNER_WORKERS,SILO_MATCHER_WORKERS) can differ between servers, so whether the stored row is restored depends on which server runs the job, as with an admin save on that server.Follow-ups:
dark:variant follows the operating system's color scheme instead of Silo's theme, so warning text such as the restore page's amber messages changes color on a theme that didn't (follow-up run started).Checklist
Council review
Rounds: 2, last reviewed 34137b3
Fixed: the Restart badge now shows only on rows a restore writes (Sol S3, then Kody's note about cleared rows). Answered: a process-scope variable set on only some API servers (Sol S1). Fixed: a held mail connection's switch and transport are labeled
managed_by_environmenttoo, so the Email page names the environment (Gemini G1). Filed: English restore explanations and pages mixing kept-back reasons, which predate this change (Sol S2, Gemini G2, #4669).Visual review: 1 round, captures from
47f89499Answered: the repeated reason under the can't-be-restored heading and the kept rows' emphasis follow the existing pattern every blocked reason shares; the light-theme color mismatch predates this change and has its own follow-up.
AI Disclosure
xhighcode review (three finders and a sweep) moved the rule to the full restore's outbound bundles after it found the plain-text transport case, shared the environment lookup with the save refusal, and added the all-environment page test. A simplify pass ran. See Council review.🤖 Generated with Claude Code
Note
Exclude environment-managed settings from selective backup restore
managed_by_environmentstatus, and leave them out of the restore (selective_settings.go).keepEnvironmentBundles.RestoreTargetsgains an optionalEnvironmentValuecallback, wired fromAdminHandler.EnvironmentSetting(admin.go, backup_restore_wiring.go).planSettings,applySettingsPage, and themanaged_by_environmentenum additions in admin_backup_restore.go and schema.ts. Restore-setting rows now show the restart badge only fordiffersandclearedstatuses.Macroscope summarized b6f8eb9.