Skip to content

feat(backup): restore from a backup uploaded from another server - #3400

Merged
Quick104 merged 2 commits into
mainfrom
feat/backups-4-upload
Nov 5, 2026
Merged

Quick104 merged 2 commits into
mainfrom
feat/backups-4-upload

Conversation

@Quick104

@Quick104 Quick104 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: #2313
Validation tasks: changes #1197 C1 (an uploaded restore set opens the same account restore, another web admin path that creates accounts); changes #1235 C1 and C2 (restoring accounts from an upload can replace notification preferences)

Selective restore works only with the backups a server took itself. Moving to
a new server, or recovering one server's settings and users onto another,
needs a way to bring another server's backup in. This lets an admin upload
another server's restore set and restore from it with the same preview and
rules.

Stacked on #3399.

Approach

  • Upload in parts: each part goes straight to the shared operational
    store, and the session state lives in PostgreSQL, so any API server can
    take any part. Each attempt is its own object, and a database row names the
    copy that counts, so a late or failed attempt never replaces a good part.
  • Limits: 2 GiB per upload and three uploads in progress per server.
    Space is reserved across servers before any byte is written. A part must
    arrive within 2 minutes, and its storage write stops after 5.
  • Completion runs under the backup lock. It reads the parts through the
    same hardened reader, freezes the SHA-256, and rejects a file that isn't a
    restore set, comes from a newer Silo, or doesn't match a SHA-256 the upload
    declared. Previews and restores are bound to the frozen digest.
  • Another SECRET_KEY: a restore set from a server with another key still
    opens, but this server can't read its encrypted settings or plugin
    configuration, so it never offers them (key_matches is false). An upload
    is always unverified, so the admin confirms before the preview opens.
  • Cleanup: abandoned uploads go after 24 hours, and unused complete ones
    after 7 days, never while a restore is queued from them.
  • UI: an upload dialog with progress, resume and clear errors, and an
    "Uploaded backups" list.

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: this pull request's contract tests pass (46 for the stack so far), covering parts sent to two servers, space reservation, deadlines, sweeping and hostile uploads.
  • Uploaded a 452 MB restore set from a development server to a fresh sandbox: 7 s to upload, 13 s to check, and the digest matched the downloaded file.
  • Revalidated on November 5, 2026 at the same head (the stack already sits on current main). On a sandbox built from feat(backup): restore accounts and profiles, and export your own data #3399, took a backup and downloaded its restore set. Rebuilt from this branch, uploaded it through the dialog, previewed it after confirming the unverified prompt, and restored a deleted account from it. Also checked that the browser and the server reject a file that isn't a restore set, that a declared SHA-256 mismatch is rejected, and that a request for 3 GiB gets 413. The test sandboxes share one SECRET_KEY, so the other-key case rests on TestRestoreFromUploadDB. The internal/backup and internal/adminjob database tests pass with PostgreSQL 18 client tools: 488 passed, none skipped.

Evidence

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

Risks

  • Migration: upload session, part and attempt tables, plus a column on
    backup_status. Additive.
  • Shared code: relies on fix(blobstore): stop a local write when its request is cancelled #3394, now on main, which stops a local
    write when its request is cancelled.
  • Lock time: completion holds the backup lock for up to 10 minutes on a
    slow store. A nightly run that starts then records a skip.

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 from backups uploaded from another server

  • Adds a full backup subsystem: nightly/manual backups via pg_dump streaming, restore sets (libraries, collections, settings, plugins, home sections, users), upload sessions for restore sets from other servers, and a restore job runner with fencing, cancellation, and progress reporting
  • Adds an admin Backups UI at /admin/backups with backup list, downloads, resumable restore-set upload, a multi-step restore chooser/review/report flow, and a Your Data page for profile export/import
  • Restores run per-item inside a caller transaction with planning previews, identity matching against local content, and safety rules: access-widening settings stay stricter, live credentials are never sent to a changed endpoint, signing keys rotate, and account/policy state is compared before apply
  • Adds PostgreSQL migrations for backup status, uploads, restore follow-ups, restored account/profile mappings, and restore item outcomes; the Docker images now install postgresql-client-18
  • Risk: restore path is new and large — key entry points to review are Service.ExecuteRestore in selective_apply.go, guardRoutes in selective_settings_routes.go, and the adminjob repository CTE changes in repository.go that alter Complete/Fail/CancelWithResult to also delete restore outcome rows

Macroscope summarized b6f6b1a.

@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 multipart restore-set uploads across backup storage, PostgreSQL, the admin API, and the web interface. Uploads can be validated, previewed, and used for selective restores. Upload records and parts are retained or swept according to upload status and restore activity.

Changes: Uploaded Restore Sets

Layer / File(s) Summary
Upload storage and lifecycle
migrations/sql/..., internal/backup/upload.go, internal/backup/upload_sweep.go, internal/backup/service.go, internal/backup/status.go
Adds upload sessions, part and attempt records, size and concurrency limits, space reservations, write and check deadlines, digest validation, expiry handling, and upload-aware active status.
Restore source integration
internal/backup/selective.go, internal/backup/selective_apply.go, internal/backup/selective_plan.go, internal/apiv2/admin_backup_restore.go
Allows restore previews and jobs to use either a backup or an upload. Reports and active-operation metadata include the upload ID when relevant.
Admin API and schemas
internal/apiv2/admin_backup_uploads.go, internal/apiv2/admin_backups.go, internal/apiv2/problem.go, internal/apiv2/router.go, contracts/api/v2/*, web/src/api/v2/*
Adds upload listing, creation, part transfer, completion, deletion, preview, and restore endpoints, with upload capability fields, request and response schemas, and upload-specific errors. The API contract files also add or revise declarations for AI, API-key, access-group, account, and Autoscan operations.
Admin web workflow
web/src/App.tsx, web/src/api/v2/adminBackupUpload.ts, web/src/hooks/queries/admin/*, web/src/pages/AdminBackups.tsx, web/src/pages/AdminBackupRestore.tsx, web/src/pages/admin-backups/*
Adds upload controls, multipart progress and retry behavior, upload listing and deletion, and upload-aware restore routing and reporting.
Validation and supporting updates
internal/backup/*_test.go, internal/apiv2/admin_backups_test.go, internal/api/testdata/media_routes.txt, scripts/ci/db-contracts.txt, internal/contractledger/ledger_test.go, docs/*
Adds upload lifecycle, timeout, storage, API, and restore tests. Updates route fixtures, retry-safety declarations, database contract entries, and backup documentation.

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Admin
  participant WebUI
  participant AdminBackupUploadRoutes
  participant BackupService
  participant PostgreSQL
  participant Destination
  Admin->>WebUI: Select restore-set file
  WebUI->>AdminBackupUploadRoutes: Create upload and send parts
  AdminBackupUploadRoutes->>BackupService: Create session and store parts
  BackupService->>PostgreSQL: Record session and part state
  BackupService->>Destination: Write part objects
  WebUI->>AdminBackupUploadRoutes: Complete upload
  AdminBackupUploadRoutes->>BackupService: Validate parts and restore set
  BackupService->>Destination: Read ordered parts
  BackupService->>PostgreSQL: Store digest and completion state
  Admin->>WebUI: Preview or start restore
  WebUI->>AdminBackupUploadRoutes: Request upload preview or restore
  AdminBackupUploadRoutes->>BackupService: Read completed upload
Loading

Possibly related PRs

Suggested labels: go, javascript, api-v2, needs-review, impact: usability, evidence-required

Merge Risk: Moderate · previous review 45930

Documented restore requests can fail, and uploads can expire sooner than documented. Resolve these issues before merging.

Security architecture risk: Low · up to 45930

Cross-server imports can affect sensitive configuration and account data. The inspected paths retain administrator authorization, explicit restore confirmation, checksum binding, and protection for queued restore sources. No material security regression was established, but deployment protections and end-to-end behavior were not fully verified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — An administrator-accepted archive can influence selected server-wide configuration, plugins, libraries, collections, and accounts in the target installation. Its impact is therefore broader than the uploading account, but application remains downstream of the shared restore checks. Deployed tenant and environment isolation were not established.

Security Findings and Attack Paths

  • observed — External archive bytes reach the restore-set parser during administrator-authorized completion, before the separate confirmation required for preview or restore. Completion uses the existing bounded reader; it does not apply the archive. Later execution validates the frozen digest before state application.

Trust Boundaries and Controls

  • observed — The upload endpoints use the existing acting-admin operation factory. Its gate chain requires authentication, viewer access, and acting-admin authorization. Service-level source selection, consent, and digest checks remain in place independently of handler request translation.
  • observed — Resource controls include a 2 GiB upload limit, three active sessions across the shared database, four concurrent part attempts per upload, admission-time reservations, and per-part free-space checks. The free-space guarantee depends on the destination providing a capacity measurement.

Resilience and Maintainability Implications

  • observed — Queueing and deletion coordinate under the backup lock, and cleanup excludes the upload named by a queued or running restore. Failure to read active restore ownership prevents protected-source deletion. Orphan-object cleanup uses durable part and attempt references plus an age grace period.
  • inferred — A preview of an already-expired upload can lose a race between its lookup and retention timestamp update. This can fail the preview, but queued and running restores have separate lock-protected retention; the race does not establish a restore-integrity bypass.
Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 71.88% 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 "feat(backup): restore from a backup uploaded from another server" matches the main change. The changeset adds multipart upload endpoints, upload storage, completion checks, and restore-from…
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 clearly explains the backup upload, validation, restore, API, database, UI, testing, and risk changes covered by the changeset.
Full details: Title check

Explanation

The title "feat(backup): restore from a backup uploaded from another server" matches the main change. The changeset adds multipart upload endpoints, upload storage, completion checks, and restore-from-upload support, all tied to restoring from another server's backup. The title names the primary feature and does not list files.

Full details: Docstring Coverage

Explanation

Docstring coverage is 71.88% 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 64 functions across 34 files. (2 skipped: 2 unsupported.)

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

@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:22:09.742373Z 5d3212d New commits
🔒 Security Review ✅ Completed 2026-11-05T16:24:17.054198Z 5d3212d New commits

Security findings

Advisory findings (3)

ℹ️ 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 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: 6e246e2276

ℹ️ 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/upload.go Resolved
@coderabbitai coderabbitai Bot added api-v2 API v2 / Huma migration program (epic #135); long-running, stacked by phase evidence-required Needs before-and-after evidence before the Evidence check passes go Pull requests that update go code impact: usability Core flow broken or severely blocked javascript Pull requests that update javascript code needs-review Needs maintainer review to resolve uncertain classification, scope, or changed evidence. labels Nov 2, 2026

@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: 2


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: 9aa54c24-2985-4f1e-8968-9289dfb4ced2
Commits

Reviewing files that changed from the base of the PR and between ffcf3f6 and 6e246e2.

Files selected for processing: 43
  • 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/testdata/media_routes.txt
  • internal/apiv2/admin_backup_restore.go
  • internal/apiv2/admin_backup_uploads.go
  • internal/apiv2/admin_backups.go
  • internal/apiv2/admin_backups_test.go
  • internal/apiv2/problem.go
  • internal/apiv2/router.go
  • internal/backup/listing.go
  • internal/backup/lock_postgres_test.go
  • internal/backup/selective.go
  • internal/backup/selective_apply.go
  • internal/backup/selective_plan.go
  • internal/backup/service.go
  • internal/backup/snapshot.go
  • internal/backup/status.go
  • internal/backup/upload.go
  • internal/backup/upload_limits_postgres_test.go
  • internal/backup/upload_postgres_test.go
  • internal/backup/upload_sweep.go
  • internal/blobstore/filesystem.go
  • internal/blobstore/filesystem_test.go
  • internal/contractledger/ledger_test.go
  • migrations/sql/20261031204725_backup_uploads.sql
  • scripts/ci/db-contracts.txt
  • web/src/App.tsx
  • web/src/api/v2/adminBackupUpload.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/backupUploads.ts
  • web/src/pages/AdminBackupRestore.tsx
  • web/src/pages/AdminBackups.tsx
  • web/src/pages/admin-backups/RestoreRun.tsx
  • web/src/pages/admin-backups/UploadBackupDialog.tsx
  • web/src/pages/admin-backups/UploadedBackups.tsx
  • web/src/pages/admin-backups/backupPresentation.ts
  • web/src/pages/admin-backups/uploadModel.test.ts
  • web/src/pages/admin-backups/uploadModel.ts
Files not fully reviewed because their changes were unavailable: 2
  • contracts/api/v2/openapi.json
  • 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.

Comment thread docs/architecture/backups.md Resolved
Comment thread internal/apiv2/admin_backup_uploads.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: 61fc36102f

ℹ️ 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/upload_sweep.go Resolved
@macroscopeapp

macroscopeapp Bot commented Nov 2, 2026

Copy link
Copy Markdown

Minor validation impact: the upload restore route reuses the selective Users restore flow and adds another web-admin path to create eligible restored accounts, affecting #1197 C1; invitation acceptance in C2 is unchanged. It can also import notification preferences when that data type is selected, adding a path that can change event preferences covered by #1235 C1 and C2. These are minor changes and need re-check after merge.

The PR body currently says Validation tasks: none. Suggested replacement:

Validation tasks: changes #1197 C1; changes #1235 C1 and C2

Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed.

Posted via Macroscope — v1 validation impact

@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: b9bbab4c20

ℹ️ 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 web/src/api/v2/adminBackupUpload.ts 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: b9bbab4c20

ℹ️ 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/apiv2/admin_backup_uploads.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: 7a53ce51-3d96-469a-a93b-06fda163fb0a
Commits

Reviewing files that changed from the base of the PR and between 6e246e2 and b9bbab4.

Files selected for processing: 16
  • docs/architecture/backups.md
  • docs/backups-api.md
  • internal/api/backup_restore_wiring.go
  • internal/apiv2/admin_backup_uploads.go
  • internal/backup/selective.go
  • internal/backup/selective_apply.go
  • internal/backup/selective_apply_test.go
  • internal/backup/service.go
  • internal/backup/upload.go
  • internal/backup/upload_limits_postgres_test.go
  • internal/backup/upload_postgres_test.go
  • internal/backup/upload_sweep.go
  • web/src/hooks/queries/admin/backupRestore.ts
  • web/src/hooks/queries/admin/backupUploads.ts
  • web/src/pages/admin-backups/UploadBackupDialog.tsx
  • web/src/pages/admin-backups/backupPresentation.ts
Files skipped from review as they are similar to previous changes: 1
  • internal/api/backup_restore_wiring.go

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

@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: 7431683c75

ℹ️ 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.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: 7031a8ac43

ℹ️ 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/upload.go Resolved
Comment thread docs/backups-api.md Resolved
Comment thread docs/backups-api.md Resolved
Comment thread internal/backup/upload.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: 97dda4a8d3

ℹ️ 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".

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

Follow-up Comments

Outside diff Document the upload verification exception without splitting the existing sentence.

532-532: Minor · Maintainability & Code Quality · Quick win

Document the upload verification exception without splitting the existing sentence.

Upload completion decodes the restore set while computing its digest. When a declared SHA-256 is supplied, checkUpload compares it with the computed digest before the accepted digest is persisted. Preview and restore verify the archive before decoding its documents. Insert this paragraph after the existing verification paragraph, not after the trailing “The”.

📝 Suggested fix
-**Nothing inside a restore set is decoded before it is verified.** The
-manifest records the restore set's digest and the digest of its index
+**Nothing inside a restore set is decoded before it is verified, except at upload completion.**
+The manifest records the restore set's digest and the digest of its index
...
+At upload completion, reading the restore set computes its digest and decodes
+its documents. If a declared SHA-256 is supplied, the computed digest is
+compared with it before the accepted digest is persisted. Preview and restore
+verify the archive before they decode its documents.

Open the source location

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: 2fb25a3e-8600-47c1-81e0-f455566263f3
Commits

Reviewing files that changed from the base of the PR and between 97dda4a and 459301f.

Files selected for processing: 7
  • contracts/api/v2/breaking-approvals.json
  • docs/architecture/backups.md
  • internal/backup/lock_postgres_test.go
  • internal/backup/selective_apply_test.go
  • internal/backup/selective_plan.go
  • internal/backup/service.go
  • internal/backup/status.go

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

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

1 similar comment
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@Quick104

Quick104 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor Author

On CodeRabbit's review 5750373621 (docs/architecture/backups.md, "Nothing inside a restore set is decoded before it is verified"): fixed in 9369962. The code now keeps the invariant where it can, and the doc states the one exception.

  • With a declared SHA-256. Upload completion (checkUploadParts) hashes the whole staged file first and compares it with the declared value. Only a match is decoded. A mismatch is rejected as checksum before anything is decoded. The second pass is covered by the same check deadline, raised to 20 minutes.
  • Without a declared SHA-256. The set is decoded unverified. The reader's bounds alone apply: the tar guard, the entry and size caps, jsonsize before each document, and DecodeStrict with CheckBounds. Such a set can be restored only with the admin's confirmation that it is unauthenticated. The doc names this exception and these bounds.
  • Test. TestUploadRejectsHostileArchivesDB (the existing table) adds bytes that are neither a restore set nor the declared ones. They are rejected as checksum, which shows they were never decoded.

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

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

1 similar comment
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@Quick104
Quick104 force-pushed the feat/backups-3-accounts branch from 4b0cdf8 to 9294db8 Compare November 4, 2026 17:10
@Quick104
Quick104 force-pushed the feat/backups-4-upload branch from 3667e7b to 7c04a12 Compare November 4, 2026 17:10
@Quick104
Quick104 force-pushed the feat/backups-3-accounts branch from 9294db8 to 07eed10 Compare November 4, 2026 20:56
@Quick104
Quick104 force-pushed the feat/backups-4-upload branch from 7c04a12 to e809f8f Compare November 4, 2026 20:56

@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: e809f8f774

ℹ️ 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/apiv2/admin_backup_uploads.go Resolved
@Quick104
Quick104 force-pushed the feat/backups-3-accounts branch from 07eed10 to 2286fc2 Compare November 5, 2026 05:11
@Quick104
Quick104 force-pushed the feat/backups-4-upload branch from e809f8f to 9d42e81 Compare November 5, 2026 05:11
@Quick104
Quick104 force-pushed the feat/backups-3-accounts branch from 2286fc2 to 5f186af Compare November 5, 2026 06:26
@Quick104
Quick104 force-pushed the feat/backups-4-upload branch from 9d42e81 to 671c47c Compare November 5, 2026 06:26
@Quick104
Quick104 force-pushed the feat/backups-3-accounts branch from 5f186af to e1b64ae Compare November 5, 2026 15:19
@Quick104
Quick104 force-pushed the feat/backups-4-upload branch from 671c47c to b6f6b1a Compare November 5, 2026 15:19
@Quick104
Quick104 force-pushed the feat/backups-3-accounts branch from e1b64ae to 17b9879 Compare November 5, 2026 16:17
Base automatically changed from feat/backups-3-accounts to main November 5, 2026 16:18
Quick104 and others added 2 commits November 5, 2026 11:18
Adds uploads: an admin uploads another server's restore set in resumable
parts, the server checks it whole (hashing it first when a SHA-256 was
declared) under the backup lock, and the page previews and restores from
it like a local backup, with the admin's confirmation since nothing in an
upload can be authenticated. Abandoned uploads and checks are swept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The completion's response deadline was 15 minutes while its check may
read the parts for 20, so a check that ran long finished after the
connection's deadline and its answer was lost. The deadline now derives
from backup.UploadCheckTimeout with two minutes to answer.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Quick104
Quick104 force-pushed the feat/backups-4-upload branch from b6f6b1a to 5d3212d Compare November 5, 2026 16:18
@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 3fa61b8 into main Nov 5, 2026
13 checks passed
@Quick104
Quick104 deleted the feat/backups-4-upload branch November 5, 2026 16:19
Comment on lines +52 to +53
function fullyReceived(upload: AdminBackupUpload): boolean {
return upload.status === "uploading" && upload.received_parts === upload.part_count;

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 Bug medium

Interrupted upload checks cannot be retried from the uploads list

An interrupted completion can leave an upload in checking without a retry action. Allow fully received uploads in checking to be completed again; the backend serializes completion with the backup lock.

Prompt for LLM
File web/src/pages/admin-backups/UploadedBackups.tsx, lines 52-53:

Interrupted upload checks cannot be retried from the uploads list

An interrupted completion can leave an upload in `checking`, but this predicate hides the retry action, leaving the administrator unable to recover it from the list. Allow a fully received `checking` upload to be completed again; the backend serializes completion with the backup lock.

Suggested code:

return (upload.status === "uploading" || upload.status === "checking") && upload.received_parts === upload.part_count;

Talk to Kody by mentioning @kody

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

​

​

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

Labels

api-v2 API v2 / Huma migration program (epic #135); long-running, stacked by phase enhancement New feature or request evidence-required Needs before-and-after evidence before the Evidence check passes go Pull requests that update go code impact: usability Core flow broken or severely blocked javascript Pull requests that update javascript code needs-review Needs maintainer review to resolve uncertain classification, scope, or changed evidence. 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