Skip to content

feat(backup): restore chosen settings, plugins, libraries, collections and home sections - #3398

Merged
Quick104 merged 5 commits into
mainfrom
feat/backups-2-selective-restore
Nov 5, 2026
Merged

Quick104 merged 5 commits into
mainfrom
feat/backups-2-selective-restore

Conversation

@Quick104

@Quick104 Quick104 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: #2313
Validation tasks: none

A full restore replaces everything. An admin who broke one settings page,
removed a plugin, or lost a set of collections has to roll the whole server
back, which discards every change made since. They also can't bring
configuration from one server to another. This lets an admin open a backup in
the browser, see what differs from the server as it is now, and restore only
the parts they pick.

Stacked on #3397.

Approach

  • Restore set: each backup gains a restore set, written from the same
    snapshot as the dump. It holds versioned JSON documents for settings pages,
    plugins (with their archives and settings), libraries, collections
    (manual and starter-pack), and home sections, plus the files they reference.
    Reading it is restricted to regular files, canonical paths, no duplicates,
    bounded sizes and allowed key prefixes.
    Home sections keep their web-only switch (restore-set format 4), so a
    web-only hero row comes back web-only. A format 3 set without the field
    still reads, with the switch off.
  • Preview: compares each item with this server: same, differs, or not on
    this server. Some items can't be restored, and the preview says why: a
    missing folder, another server's key, a template this server doesn't have.
    Settings use an allowlist, so settings specific to a server (identity,
    public URL, storage, the push relay, the sign-in key, search, backups) are
    never offered. A test makes every new setting choose a class.
  • Matching: libraries match only on an identical folder set. Collections
    and sections match by their backup id first, then by name with exactly one
    candidate, and two backup items never claim the same item here.
  • Apply: an admin job takes a "before restore" backup first, then
    restores item by item. Each item's transaction locks the job row through
    commit, so a stalled worker can't write after the job is marked interrupted.
    Restored plugins are installed disabled and enabled only after their
    settings pass validation. Files are created only if absent, so a restore
    never overwrites a live file. Setup that runs after commit, such as a new
    library's first scan and provider chain or a new collection's sync, is
    recorded in the same transaction and retried until it succeeds. Running the
    same restore twice changes nothing.
  • UI: Choose, Review and Restore steps with a difference bar per section,
    sections with nothing to restore collapsed to one line, grouping by library
    and a filter for large sections, and a report per item.

Validation

  • Go: gofmt, build, go vet, and changed-line golangci-lint against the previous pull request: pass.
  • Contract and repository checks: verify-apiv2-openapi, -web-types, -fixtures, -contract (additive only), verify-migrations, verify-migration-ledger, verify-size-ratchet, verify-local-paths, verify-settings-bindings: pass.
  • Web: tsc -b, eslint and prettier on changed files, and vitest: pass.
  • verify-route-inventory: pass.
  • Database tests against PostgreSQL 18: the 22 contract tests this pull request adds pass, covering fencing, interruption, idempotency, identity matching and the hostile-archive reader. They don't build on feat(backup): take nightly backups and restore a whole server #3397, since the code they test is new here.
  • Restored a development server's backup into a fresh sandbox: 2 libraries, a plugin, a settings page, 100 starter-pack collections and 14 home sections restored with no failures, and a second preview showed all of them unchanged.
  • Rechecked on 59908fa, on top of feat(backup): take nightly backups and restore a whole server #3397 at a88bc5a (which includes current main), in a fresh sandbox. After a backup, a setting was changed, then a manual collection, a library, and its 8 sections were deleted, and a home section was edited. A restore from the browser brought back all 12 items with no failures, and the second preview matched. Running the same restore again reported all 12 unchanged.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/pr-3398/

Risks

  • Migrations: four, which add the job's uniqueness, the follow-up
    table, and a table of per-item outcomes a running restore writes (its
    rows move into the job's result when the restore ends). Only additive.
  • Shared code: blob stores gain CreateExclusive (S3 If-None-Match).
    Selective restore refuses stores that can't create atomically; other writes
    are unchanged. Catalog, settings, plugin and sections write paths gain
    variants that take the caller's transaction; the existing paths behave as
    before.
  • Cost: a preview reads the whole restore set once; documents are cached
    by digest.
  • Seasonal sections: one run of the seasonal list task now fetches at
    most 200 MDBList lists and takes the rest on later runs, on every server,
    not just restored ones. A restore writes at most 50 seasonal sections, and
    those from a backup this server can't verify come back disabled.

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 says there is none.

AI Disclosure

  • Harness: T3 Code with Claude Code
  • Tool(s): Claude Code with subagents; OpenAI Codex CLI for independent review
  • Model(s): claude-opus-5-5; gpt-6.1-sol (review)
  • Involvement: Fully AI-generated. The maintainer tested the backups work it came from on a development server; the diff awaits human review.
  • Adversarial review: gpt-6.1-sol reviewed the backups work read-only in repeated rounds; every finding was fixed or answered before this branch was cut.

🤖 Generated with Claude Code

Note

Add selective restore of settings, plugins, libraries, collections and home sections

  • Backups now include a restore-set.tar object (format v4): a versioned JSON archive with sections for settings, plugins, libraries, collections, and home sections, plus referenced blobs. See restoreset.go and restoreset_write.go.
  • Selective restore runs as a backup_restore admin job (backup_restore.go) holding the subsystem lock for the whole run. It takes a before-restore backup first, applies selected items in fenced transactions, and reports per-item outcomes.
  • A preview API compares backup items with the current server and shows dependency-aware selection in a new three-step UI (Choose / Review / Restore). Previews share one parsed, cached restore set per digest.
  • Restores that change a service endpoint clear live credentials the backup does not supply and turn the service off; unverified backups skip external-service settings and other risky fields.
  • Follow-up work (library scans, plugin chains, sections, collections) is recorded in new backup_restore_followups and backup_restore_items tables and retried after failures.
  • Risk: rotation and deletion now refuse to remove backups that are the source of a queued or running restore; before-restore copies expire after 7 days and do not count toward the keep limit. Blob stores without atomic exclusive creates (ExclusiveCreator in exclusive.go) cannot restore blobs.

Macroscope summarized cc385e7.

@silo-triage silo-triage Bot added the size/XXXL 3000+ added + deleted lines (all files); change volume, not priority. label Nov 2, 2026
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review
Walkthrough

The pull request adds selective backup restore through versioned restore-set archives, preview and item selection, cancellable restore jobs, transactional application, API endpoints, and an administrative interface. It also adds before-restore backups and retention, restore-source protection, and exclusive blob creation.

Changes: Selective backup restore

Layer / File(s) Summary
Restore-set archive and backup lifecycle
internal/backup/*, internal/blobstore/*, internal/s3client/*
Backups now include versioned restore-set.tar archives. The service validates and caches previews, supports restore-set downloads, creates before-restore backups, pins active restore sources during rotation, and uses exclusive blob writes.
Restore planning and application
internal/backup/selective*.go, internal/backup/restore_settings.go, internal/backup/userdata/*, internal/plugins/restore.go, internal/sections/mutations.go
The service previews restore items, validates selection and digest data, and applies selected settings, plugins, libraries, collections, artwork, branding, and page sections. It records item outcomes and durable follow-ups, and remaps library and collection references.
Transactional restore integrations
internal/api/handlers/*, internal/catalog/*, internal/metadata/*, internal/api/backup_restore_wiring.go, migrations/sql/*
Handlers and repositories add transaction-scoped operations and restore callbacks. Restore wiring connects settings, plugin, library, artwork, template-collection, and section targets. Migrations constrain active restore jobs and store pending follow-ups.
Admin jobs and API
internal/adminjob/*, internal/apiv2/*, cmd/silo/*, internal/api/router.go, contracts/api/v2/*
Backup restores run as cancellable, fenced admin jobs. The API adds restore preview and start endpoints, restore-set downloads, conflict responses, and restore source and report fields.
Administrative web interface
web/src/App.tsx, web/src/api/v2/*, web/src/hooks/queries/admin/*, web/src/pages/AdminBackupRestore.tsx, web/src/pages/admin-backups/*
The web application adds restore routing, preview and job queries, dependency-aware selection, review, progress, cancellation, and report views. The backup list links to restore flows and active restore jobs.

Estimated code review effort: 5 (Critical) | ~120 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant AdminUI
  participant AdminAPI
  participant BackupService
  participant AdminJobRunner
  participant Database
  AdminUI->>AdminAPI: request restore preview
  AdminAPI->>BackupService: Preview backup
  BackupService-->>AdminAPI: return restore preview
  AdminUI->>AdminAPI: submit digest and selection
  AdminAPI->>BackupService: StartRestore
  BackupService->>Database: queue backup_restore job
  AdminJobRunner->>BackupService: ExecuteRestore
  BackupService->>Database: commit fenced item progress
  BackupService-->>AdminJobRunner: return restore report
  AdminJobRunner-->>AdminAPI: expose job result
Loading

Suggested reviewers: rhainland

Merge Risk: Low · previous review eefa3

Selective restore adds a narrow startup race: a scheduled backup rotation can delete the source of a queued restore if it runs before restore protection is wired. This is unlikely and bounded, but it is worth fixing by installing the active-restore lookup before the task manager starts.

Security architecture risk: Moderate · up to eefa3

The restore flow has broad authority over server configuration and plugins. Administrator access checks and per-item transactions reduce exposure, but startup timing can leave a queued restore source unprotected, and rolled-back plugin installations can leave files behind.

Retained concerns

  • Medium · reliability · inferred: Queued restore sources are not protected throughout startup. Backup scheduling starts before router construction installs the active-restore lookup, and a missing lookup is treated as no active restore. If an enabled scheduled backup reaches rotation during that window, an otherwise retention-eligible queued source can be deleted. This affects recovery-source availability, not unauthorized restoration. After wiring completes, rotation checks queued jobs, and restore execution explicitly pins its source.
  • Low · reliability · inferred: The new transaction-backed plugin restore path retains an extracted installation directory before the enclosing item and fenced job transaction commit. A subsequent configuration write, follow-up insertion, or outer commit failure rolls back database ownership without removing that directory. The installer already retained directories on success before this PR, but the new caller-owned transaction introduces this later rollback window. Ordinary installer failures remove the directory; rolled-back rows do not expose it as an enabled plugin. The remaining issue is incomplete rollback ownership and storage accumulation across failed attempts.
Security review details

Security Blast Radius

  • inferred — The visible mutation scope extends beyond backup storage to server settings, plugin installations and configuration, libraries, collections, home sections, and referenced assets. An administrator's selected backup content therefore crosses into live server state. Exposure across additional environments or independently operated services was not established.

Trust Boundaries and Controls

  • observed — The new operations use the acting-administrator classification. Restored settings must pass an explicit portability allowlist and then the normal settings normalization, validation, and managed-setting checks; server identity, credentials, storage, and other server-specific settings are excluded from this restore path.
  • observed — A missing plugin is installed through the archive installer with intermediate enablement disabled. Source configuration is decrypted using its source installation identity, validated against the installed manifest, and re-encrypted for the target identity. A new installation is enabled only when requested and configuration was neither unreadable nor rejected. Existing installations retain their enabled state.

Resilience and Maintainability Implications

  • observed — The per-item fence locks the running job row and checks its claim through commit, coupling restored database state with reported progress. Stale recovery uses that same row and marks restores interrupted instead of requeueing them. Cancellation is checked between items, preserving an item's transaction boundary rather than promising immediate interruption.

Hardening Proposals

  • proposed — Install active-restore source protection before backup scheduling can run, or make retention fail closed until that protection is initialized. Couple newly extracted plugin directories to an enclosing-transaction cleanup or durable reconciliation mechanism.
Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 72.28% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed

Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: selective restoration of chosen backup content, including settings, plugins, libraries, collections, and home sections.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The pull request description directly describes the selective backup restore functionality, including restore-set creation, preview and apply flows, admin jobs, API and UI changes, migrations, validat…
Full details: Description check

Explanation

The pull request description directly describes the selective backup restore functionality, including restore-set creation, preview and apply flows, admin jobs, API and UI changes, migrations, validation, and risks covered by the changeset.

Full details: Docstring Coverage

Explanation

Docstring coverage is 72.28% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 184 functions across 62 files. (5 skipped: 4 unsupported, 1 too large.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • 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: a279bceb-dc33-4e54-b813-2c1917cc934b
Commits

Reviewing files that changed from the base of the PR and between 177c9b9 and eefa35e.

Files selected for processing: 20

  • cmd/silo/main.go
  • contracts/api/v2/openapi.json
  • docs/architecture/backups.md
  • internal/api/handlers/plugins.go
  • internal/api/router.go
  • internal/api/testdata/media_routes.txt
  • internal/apiv2/problem.go
  • internal/backup/layout.go
  • internal/backup/manifest.go
  • internal/backup/selective_postgres_test.go
  • internal/backup/selective_templates.go
  • internal/backup/service.go
  • internal/blobstore/filesystem.go
  • internal/catalog/folder_repo.go
  • internal/catalog/library_collection_mutations.go
  • internal/catalog/library_collection_repo.go
  • internal/contractledger/ledger_test.go
  • internal/plugins/installation.go
  • scripts/ci/db-contracts.txt
  • web/src/api/v2/schema.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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-05T16:20:17.541101Z cc385e7 New commits
🔒 Security Review ✅ Completed 2026-11-05T16:30:05.979244Z cc385e7 New commits

Security findings

Advisory findings (26)

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@silo-triage silo-triage Bot added enhancement New feature or request go Pull requests that update go code priority: P2 Limited scope, workaround exists, or polish stacked Base is another open PR; merge in stack order named in the body labels Nov 2, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e11852d0e3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/backup/selective_sections.go Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8a62296658

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 865944794a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/sections/mutations.go Resolved
Comment thread internal/backup/selective_sections.go Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f614f19f6b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/sections/mutations.go Resolved

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 3


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: 5f01140e-da09-49c3-94eb-4b444282d79a
Commits

Reviewing files that changed from the base of the PR and between 0a99580 and f614f19.

Files selected for processing: 102
  • cmd/silo/backup_wiring.go
  • cmd/silo/main.go
  • contracts/api/v2/breaking-approvals.json
  • contracts/api/v2/openapi.json
  • docs/admin-tasks-api.md
  • docs/architecture/backups.md
  • docs/architecture/blob-storage.md
  • docs/backups-api.md
  • internal/adminjob/backup_restore.go
  • internal/adminjob/backup_restore_test.go
  • internal/adminjob/repository.go
  • internal/adminjob/runner.go
  • internal/api/backup_restore_wiring.go
  • internal/api/handlers/admin.go
  • internal/api/handlers/admin_images.go
  • internal/api/handlers/libraries.go
  • internal/api/handlers/libraries_service.go
  • internal/api/handlers/library_collection_restore.go
  • internal/api/handlers/library_collections.go
  • internal/api/handlers/library_restored_test.go
  • internal/api/handlers/plugin_restore.go
  • internal/api/handlers/plugins.go
  • internal/api/router.go
  • internal/api/testdata/media_routes.txt
  • internal/apiv2/admin_backup_restore.go
  • internal/apiv2/admin_backups.go
  • internal/apiv2/admin_backups_test.go
  • internal/apiv2/admin_task_jobs.go
  • internal/apiv2/problem.go
  • internal/backup/doc.go
  • internal/backup/downloads.go
  • internal/backup/layout.go
  • internal/backup/listing.go
  • internal/backup/manifest.go
  • internal/backup/manifest_test.go
  • internal/backup/restore_settings.go
  • internal/backup/restore_settings_test.go
  • internal/backup/restoreset.go
  • internal/backup/restoreset_cache.go
  • internal/backup/restoreset_cache_test.go
  • internal/backup/restoreset_read.go
  • internal/backup/restoreset_read_test.go
  • internal/backup/restoreset_write.go
  • internal/backup/rotation.go
  • internal/backup/rotation_test.go
  • internal/backup/selective.go
  • internal/backup/selective_apply.go
  • internal/backup/selective_apply_test.go
  • internal/backup/selective_identity.go
  • internal/backup/selective_plan.go
  • internal/backup/selective_postgres_test.go
  • internal/backup/selective_sections.go
  • internal/backup/selective_templates.go
  • internal/backup/service.go
  • internal/backup/status_test.go
  • internal/backup/stored.go
  • internal/backup/userdata/userdata.go
  • internal/blobstore/exclusive.go
  • internal/blobstore/exclusive_test.go
  • internal/blobstore/filesystem.go
  • internal/catalog/artwork_selection.go
  • internal/catalog/encrypted_settings_repo.go
  • internal/catalog/folder_repo.go
  • internal/catalog/library_collection_group_repo.go
  • internal/catalog/library_collection_repo.go
  • internal/catalog/library_collection_service.go
  • internal/catalog/server_settings_repo.go
  • internal/config/admin_settings.go
  • internal/contractledger/ledger_test.go
  • internal/metadata/capability_metadata.go
  • internal/metadata/chain.go
  • internal/plugins/installation.go
  • internal/plugins/installer.go
  • internal/plugins/restore.go
  • internal/plugins/restore_test.go
  • internal/s3client/client.go
  • internal/sections/mutations.go
  • migrations/sql/20261031164741_backup_restore_active_job.sql
  • migrations/sql/20261031173353_backup_restore_followups.sql
  • migrations/sql/20261101030252_backup_restore_followup_collections.sql
  • scripts/ci/db-contracts.txt
  • web/src/App.tsx
  • web/src/api/v2/adminBackupRestore.ts
  • web/src/api/v2/adminBackups.ts
  • web/src/api/v2/operations.ts
  • web/src/api/v2/schema.ts
  • web/src/hooks/queries/admin/backupRestore.ts
  • web/src/hooks/queries/admin/backups.ts
  • web/src/pages/AdminBackupRestore.tsx
  • web/src/pages/AdminBackups.tsx
  • web/src/pages/admin-backups/BackupSettings.tsx
  • web/src/pages/admin-backups/BackupTable.tsx
  • web/src/pages/admin-backups/RestoreChoose.tsx
  • web/src/pages/admin-backups/RestoreReview.tsx
  • web/src/pages/admin-backups/RestoreRows.tsx
  • web/src/pages/admin-backups/RestoreRun.tsx
  • web/src/pages/admin-backups/backupPresentation.test.ts
  • web/src/pages/admin-backups/backupPresentation.ts
  • web/src/pages/admin-backups/restoreGroups.test.ts
  • web/src/pages/admin-backups/restoreGroups.ts
  • web/src/pages/admin-backups/restoreModel.test.ts
  • web/src/pages/admin-backups/restoreModel.ts
Files with no reviewable changes: 1
  • internal/backup/status_test.go

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

Comment thread internal/blobstore/filesystem.go Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 112edd24d9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/backup/selective_apply.go Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4f7320b380

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/backup/restoreset_read.go Resolved

@coderabbitai coderabbitai Bot 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 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: 8c76844e-f8a4-4463-bfb7-629a6c9926b3
Commits

Reviewing files that changed from the base of the PR and between f614f19 and 4f7320b.

Files selected for processing: 8
  • internal/api/backup_restore_wiring.go
  • internal/backup/selective.go
  • internal/backup/selective_apply.go
  • internal/backup/selective_postgres_test.go
  • internal/blobstore/filesystem.go
  • internal/sections/mutations.go
  • web/src/hooks/queries/admin/backupRestore.ts
  • web/src/pages/admin-backups/backupPresentation.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.

Comment thread internal/backup/selective_apply.go Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2eafd46ec8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/backup/restore_settings.go Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 500911a8ec

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/backup/selective_templates.go Resolved
Comment thread internal/api/router.go Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3b70adcc5b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/backup/selective_plan.go Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f0096925cc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4e2c34e7a3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/backup/selective_apply.go Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛡️ Codex Security Review · Automatically triggered

Here are some automated security review suggestions for this pull request.

Reviewed commit: d913dd1a68

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread internal/plugins/restore.go Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛡️ Codex Security Review · Automatically triggered

Here are some automated security review suggestions for this pull request.

Reviewed commit: 2ca3e2c529

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread internal/backup/restore_settings.go Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 610eca30a0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/sections/mutations.go Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛡️ Codex Security Review · Automatically triggered

Here are some automated security review suggestions for this pull request.

Reviewed commit: 610eca30a0

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread internal/backup/selective_artwork.go Resolved
Comment thread internal/backup/selective.go Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛡️ Codex Security Review · Automatically triggered

Here are some automated security review suggestions for this pull request.

Reviewed commit: cd51410618

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread internal/backup/restoreset_read.go Resolved
Comment thread internal/backup/restore_settings.go Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3d3f9ba29b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/backup/selective_apply.go Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛡️ Codex Security Review · Automatically triggered

Here are some automated security review suggestions for this pull request.

Reviewed commit: 3d3f9ba29b

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread internal/backup/restoreset_read.go Resolved
@Quick104
Quick104 force-pushed the feat/backups-1-core branch from a1e3bc2 to a88bc5a Compare November 5, 2026 05:11
@Quick104
Quick104 force-pushed the feat/backups-2-selective-restore branch from 4dd1d69 to 59908fa Compare November 5, 2026 05:11

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛡️ Codex Security Review · Automatically triggered

Here are some automated security review suggestions for this pull request.

Reviewed commit: 1694f84404

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread internal/backup/selective_sections.go Resolved
@Quick104
Quick104 force-pushed the feat/backups-1-core branch from a88bc5a to e95fa0f Compare November 5, 2026 14:51
@Quick104
Quick104 force-pushed the feat/backups-2-selective-restore branch from 1694f84 to d8bceb0 Compare November 5, 2026 15:19

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛡️ Codex Security Review · Automatically triggered

Here are some automated security review suggestions for this pull request.

Reviewed commit: d8bceb0e1c

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread internal/backup/restoreset_decode.go Resolved
@Quick104
Quick104 force-pushed the feat/backups-1-core branch from 5985f25 to d078884 Compare November 5, 2026 16:11
Base automatically changed from feat/backups-1-core to main November 5, 2026 16:13
Quick104 and others added 5 commits November 5, 2026 11:13
…s and home sections

Adds the selective restore: each backup carries a restore set, a
versioned archive of settings, plugins, libraries, collections, home
sections and templates, which the page previews against this server and
restores item by item as an admin job under the backup lock. A restore
from a backup this server cannot authenticate needs the admin's
confirmation, turns off whatever would reach outside services or cost
money until an admin turns it on, and reports each item's outcome.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The report read "Added 1 items to the collection here and put it back in
0 groups." It now names the items and the groups only when there were
any, with the noun matching the count.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ntil the report

A collection in a restore set may list each item once: one that repeats
an item is left out as unusable, so a crafted document cannot multiply
the work its restore does under the lock.

A selective restore removed its item outcome rows as soon as it read them
back, before the job recorded its final report, so a crash in between
lost every outcome but the latest. The rows now go in the statement that
records the report: Complete, Fail, CancelWithResult, or stale recovery.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
page_sections.web_only keeps a featured row on the web app alone. The
restore set left it out, so restoring a deleted web-only hero row brought
it back on every client, and one whose switch was turned off since looked
the same as the backup.

Restore-set format 4 carries web_only in home-sections.json; a set of an
earlier format reads it as false, the column's default, and one that
claims an earlier format while holding it is refused. A restore writes it
on a featured row when it creates or replaces a section, and the preview
lists "web only" when it differs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…fuse repeated section items

Every enabled home section is fetched on each home page request, so a
restore set this server cannot verify now brings every section back off,
not just seasonal ones. A section's carried collection, like an admin
collection, may not list an item twice.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Quick104
Quick104 force-pushed the feat/backups-2-selective-restore branch from d8bceb0 to cc385e7 Compare November 5, 2026 16:16
@silo-kody

silo-kody Bot commented Nov 5, 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 ❌

@Quick104
Quick104 merged commit ecc5196 into main Nov 5, 2026
17 checks passed
@Quick104
Quick104 deleted the feat/backups-2-selective-restore branch November 5, 2026 16:16
if err != nil {
return fmt.Errorf("beginning fenced job transaction: %w", err)
}
defer func() { _ = tx.Rollback(context.WithoutCancel(ctx)) }()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Kody Rules high

Detached transaction rollback has no deadline

A stalled database connection can leave cleanup waiting indefinitely after the restore request is canceled. Bound the detached context passed to tx.Rollback with a fixed timeout.

Kody rule violation: Cancel blocking lifecycle work before waiting and bound detached cleanup

Prompt for LLM
File internal/adminjob/backup_restore.go, line 157:

Detached transaction rollback has no deadline

Bound the detached rollback context with a fixed timeout. Without a deadline, a stalled database connection can leave cleanup waiting indefinitely after the restore request has been canceled.

Kody rule violation: [Cancel blocking lifecycle work before waiting and bound detached cleanup](https://kodus.siloserver.org/settings/code-review/1247142351/kody-rules/6bbefdf5-b173-4ab8-aadd-04b9c38df65e?teamId=ba9922fc-c0ea-4cf8-87bb-9d4f42ffc73e)

Suggested code:

defer func() {
	rollbackCtx, cancel := context.WithTimeout(context.WithoutCancel(ctx), 2*time.Second)
	defer cancel()
	_ = tx.Rollback(rollbackCtx)
}()

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

if !filepath.IsAbs(path) {
return errors.New("path must be absolute")
}
dir, err := os.Open(filepath.Clean(path))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Kody Rules high

Library folder checks pass encoded paths directly to the OS

Encoded filenames may not match their on-disk byte representation, causing valid library folders to be rejected or the wrong path to be inspected. Open the canonical encoded path through the filesystem adapter instead of os.Open.

Kody rule violation: Respect encoded filesystem paths at every Go boundary

Prompt for LLM
File internal/api/backup_restore_wiring.go, line 137:

Library folder checks pass encoded paths directly to the OS

Open the canonical encoded path through the filesystem adapter rather than passing it directly to `os.Open`. Encoded filenames may not match their on-disk byte representation, so this check can reject a valid library folder or inspect the wrong path.

Kody rule violation: [Respect encoded filesystem paths at every Go boundary](https://kodus.siloserver.org/settings/code-review/1247142351/kody-rules/5fabedc4-ec54-48d6-99a3-d23aab81d6bb?teamId=ba9922fc-c0ea-4cf8-87bb-9d4f42ffc73e)

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cc385e7b60

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +194 to +195
key := fmt.Sprintf("%d/%t", installation.ID, trustVerified)
result := c.loads.DoChan(key, func() (any, error) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Key in-flight archive loads by release identity

On a remote plugin host with a cold cache, a load overlapping a plugin upgrade or same-version replacement can join the previous release's in-flight load: the installer preserves Installation.ID, but this key includes neither the version nor the release's install path. The shared closure rehydrates only the first caller's installation and returns its manifest directly to both callers. Consequently, Ensure for the new release can report success with the old manifest while the new release's LocalInstallPath is still absent, causing plugin startup to fail. Include the release identity in the singleflight key so different releases cannot share a result.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛡️ Codex Security Review · Automatically triggered

Here are some automated security review suggestions for this pull request.

Reviewed commit: cc385e7b60

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

// many memberships it grouped.
func restoreGroups(ctx context.Context, tx pgx.Tx, collectionID string, c CollectionEntry, libMap map[int]int) (int, error) {
grouped := 0
for _, lib := range c.Libraries {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛡️ Codex Security Review · Automatically triggered

P2 Badge Security: Reject duplicate collection memberships before restore

Requires backup-destination write access, an acting admin who accepts the unverified set, and selection of a crafted collection. Fresh evidence beyond the fixed duplicate-item finding is the separate libraries array: validation accepts duplicates, and 15,881 minimal copies fit one permitted 1 MiB entry. This loop calls groupFor and GroupUngroupedMembershipInTx for every copy, issuing tens of thousands of lock/query/update operations in one cancellation-detached transaction while the global backup lock is held. Reject duplicate library IDs and cap memberships before applying them.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request go Pull requests that update go code priority: P2 Limited scope, workaround exists, or polish size/XXXL 3000+ added + deleted lines (all files); change volume, not priority. stacked Base is another open PR; merge in stack order named in the body

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant