Skip to content

fix(plugins): guard the remaining installation writes on the package they read - #4584

Merged
Quick104 merged 5 commits into
Silo-Server:mainfrom
rangoDJ:fix/4518-guard-plugin-installation-writes
Nov 23, 2026
Merged

Quick104 merged 5 commits into
Silo-Server:mainfrom
rangoDJ:fix/4518-guard-plugin-installation-writes

Conversation

@rangoDJ

@rangoDJ rangoDJ commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Depends on: none (#4509, which adds the guard these writes use, is merged). Merge order: none.

Problem

Closes #4518
Related issue: #4509
Validation tasks: none

Other clients: N/A. Web admin plugin administration only; no client app or Jellyfin-compatible route is involved.

#4509 made a plugin replacement write only while the installation still holds the package it was prepared against (IfInstallPath, ErrInstallationChanged). Other writes to the same installation still went by ID alone, so they could undo or misreport a newer install that landed after they read the row. The issue lists four; #4602 has since fixed the archive repair (ArchiveCache.load now stores through InstallationStore.repairArchive, which writes only while the archive row still has the updated_at and bytes it read), so this PR covers the other three:

  1. The notify update pass (notifyPluginUpdate) recorded available_version by ID, so an offer decided against 1.0.0 could land after an admin installed 2.0.0, and Update would then install 1.1.0 over 2.0.0.
  2. UpdateToAvailableVersion cleared available_version a second time after the replacement had already cleared it in its own write, erasing a newer offer recorded in between.
  3. When another install cleared the offer between the handler's read and the service's, /update answered 500 instead of 409.

Approach

  1. Notify sets IfInstallPath to the snapshot's path on the available_version write and drops the offer on ErrInstallationChanged. handleExistingPlugin then reports no outcome, so the pass doesn't count a dropped offer as an available update.
  2. UpdateToAvailableVersion refuses a recorded version that isn't newer than the installed one (compareVersions), with the new plugins.ErrNoUpdateAvailable, before any download or stop. The second clear is gone; the replacement's own write already sets available_version to empty.
  3. ApplyAdminPluginUpdate maps ErrNoUpdateAvailable to the existing ErrPluginUpdateUnavailable, which apiv2 already answers as 409 conflict.
  4. The update check clears a recorded version that isn't newer than the installed one, under the same ifAvailableVersion, IfVersion and IfInstallPath guards as the withdrawn-notice clear. A row the race already wrote would otherwise keep a web admin Update button that always answers 409. Added in maintainer review (3a15117).

These follow the technical notes on the issue.

Validation

  • Not reproduced live; each race needs two overlapping operations.
  • TestNotifyPluginUpdateDropsAnOfferForAReplacedReleaseDB (Postgres): reads 1.0.0, replaces it with 2.0.0, then runs handleExistingPlugin for 1.1.0, and checks nothing was recorded and the outcome is none. Before d2f8910 the outcome was notified (2).
  • TestUpdateToAvailableVersionRefusesAnOfferNotNewerThanInstalled: an older, equal, cleared and missing offer each return ErrNoUpdateAvailable with no stop or write.
  • TestServiceInstallCatalogStopsPluginOnlyForAnAcceptedPackageDB gains an "applied update" case: the events are [update stop] (the order feat(plugins): install and configure official plugins from the environment #4602 set for this table), without the second clear.
  • Each of the three fails on main and passes with the fix (output below, recorded before the rebase onto feat(plugins): install and configure official plugins from the environment #4602).
  • go test ./internal/plugins/ ./internal/api/handlers/ ./internal/apiv2/ with a local Postgres: the only failures are DB tests that fail identically on main in this environment, whose local schema is behind: TestInstanceState*Postgres (column "version" does not exist), TestPluginInstallKeepsOneInstallationPerPluginDB (needs fix(plugins): keep one installation per plugin #4525's migration), nine api/handlers DB tests and TestScopedAdminKeyCannotRedirectRecoveryDB.
  • Rebased on main at 2c2dc7c00 (feat(plugins): install and configure official plugins from the environment #4602). Conflicts: the archive repair, where this PR's change is dropped in favour of feat(plugins): install and configure official plugins from the environment #4602's repairArchive; the notify write, which keeps both feat(plugins): install and configure official plugins from the environment #4602's automatic: true and this PR's IfInstallPath; and the install table's event order, which takes feat(plugins): install and configure official plugins from the environment #4602's [update stop].
  • After the rebase, with the local test DB migrated: internal/api/handlers passes; in internal/plugins the only failures are TestArchiveCacheRejectsSupersededSameVersionDB, TestInstallationStoreDeleteRemovesOnlyTrustedFiles and TestInstallationStoreRetiresFilesAfterCommittedDeleteDB ("plugin is already installed", leftover rows in the shared local DB), which fail the same way on main 2c2dc7c00.
  • golangci-lint run --new-from-rev=origin/main ./internal/plugins/ ./internal/api/handlers/: 0 issues.
  • Maintainer review (head 10f5fab, main merged in at 97ace34): TestAutoUpdateClearsWithdrawnNoticeDB gains a step that leaves a 1.0.0 notice on a 2.0.0 install. It failed on d2f8910 and passes with the fix. TestNotifyPluginUpdateDropsAnOfferForAReplacedReleaseDB is now listed in scripts/ci/db-contracts.txt, so CI runs it instead of skipping it. On a freshly migrated Postgres, internal/plugins/..., internal/api/handlers and internal/apiv2 all pass.
  • Not tested: the handler's mapping from ErrNoUpdateAvailable to 409 (a one-line errors.Is; the handler takes concrete stores, so it has no fake to test against), and any race across two live API servers.

Evidence

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

The new tests on main (8be54fc8c, with only the ErrNoUpdateAvailable variable added so they compile):

--- FAIL: TestNotifyPluginUpdateDropsAnOfferForAReplacedReleaseDB (0.09s)
    update_offer_test.go:46: available_version = "1.1.0", want none recorded over the 2.0.0 install
--- FAIL: TestUpdateToAvailableVersionRefusesAnOfferNotNewerThanInstalled/older (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered, repanicked]
--- FAIL: TestServiceInstallCatalogStopsPluginOnlyForAnAcceptedPackageDB/applied_update (0.05s)
    service_install_catalog_db_test.go:146: events = [stop update update], want [stop update]

The "older" case panics on main because main goes on to install the older version, and this test wires no catalog to install from.

With the fix:

--- PASS: TestNotifyPluginUpdateDropsAnOfferForAReplacedReleaseDB (0.03s)
--- PASS: TestUpdateToAvailableVersionRefusesAnOfferNotNewerThanInstalled (0.00s)
--- PASS: TestServiceInstallCatalogStopsPluginOnlyForAnAcceptedPackageDB (0.17s)
golangci-lint run --new-from-rev=origin/main ./internal/plugins/ ./internal/api/handlers/
0 issues.

Risks

  • An admin who pressed Update on a stale offer (a version not newer than the installed one) now gets a 409 instead of a downgrade.
  • No API, config or schema change.

Checklist

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

AI Disclosure

  • Harness: Claude Code in the Claude desktop app
  • Tool(s): Claude Code
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated, not yet human verified
  • Adversarial review: n/a
  • Maintainer review fixes (3a15117): Claude Code in T3 Code, claude-opus-5-5, with read-only reviews by gpt-6.2-sol, claude-opus-5-5 and gemini-4-neon

🤖 Generated with Claude Code

Note

Guard plugin update reads against stale installation state

  • Adds plugins.ErrNoUpdateAvailable in installation.go; Service.UpdateToAvailableVersion returns it for absent, empty, or non-newer offers instead of installing, and the admin handler maps it to ErrPluginUpdateUnavailable.
  • AutoUpdateService.notifyPluginUpdate uses the read install path as a conditional field; if the store returns ErrInstallationChanged, the offer is dropped as stale and handleExistingPlugin returns autoUpdateOutcomeNone instead of an error.
  • The update pass clears recorded offers for versions that are withdrawn or not newer than the installed version.
  • Risk: Service.UpdateToAvailableVersion no longer clears AvailableVersion after installation; check the replacement transaction in service.go if stale offers reappear.

Macroscope summarized 10f5fab.

@silo-triage silo-triage Bot added the size/M 50–199 added + deleted lines (all files); change volume, not priority. label Nov 19, 2026
@silo-kody

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

@silo-triage silo-triage Bot added bug Something isn't working go Pull requests that update go code priority: P2 Limited scope, workaround exists, or polish labels Nov 19, 2026
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

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

Update checks clear stale notices and guard offer writes against installation replacement. Update application rejects absent or non-newer offers, and the admin handler maps unavailable offers to its existing error.

Changes: Plugin update race handling

Layer / File(s) Summary
Guard update-offer writes
internal/plugins/auto_update.go, internal/plugins/update_offer_test.go, internal/plugins/provision_package_test.go, scripts/ci/db-contracts.txt
Update checks clear notices for withdrawn or non-newer versions. notifyPluginUpdate guards offer writes with the installation path, and the notify policy treats ErrInstallationChanged as no update found. Tests cover stale notices and offers for replaced installations.
Validate and apply recorded updates
internal/plugins/installation.go, internal/plugins/service.go, internal/api/handlers/admin_plugin_lifecycle.go, internal/plugins/update_offer_test.go, internal/plugins/service_install_catalog_db_test.go
UpdateToAvailableVersion returns ErrNoUpdateAvailable for absent, empty, or non-newer offers. The admin handler maps that error to ErrPluginUpdateUnavailable. The replacement path no longer performs a second database update to clear the offer. Tests cover unavailable offers and an applied update.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

Suggested reviewers: quick104, rhainland, coffeeknyte

Merge Risk: Low · up to 3a151

Update checks now clear stale notices, and a rare race could erase a newer update notice that was just recorded. Installations are unaffected and the next check would restore the notice, so the risk is low. Making the clear conditional on the notice it read would close the gap.

Security architecture risk: Minimal · up to 3a151

The change makes it harder for an outdated offer to overwrite or downgrade a newer plugin installation. It also preserves offers recorded after a successful replacement and returns a conflict when an offer is no longer applicable, without granting new update permissions.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed writes affect individual plugin installation rows reached by the existing background checker or admin update flow. The exported Check method is wired into the existing background task; the inspected callers did not show new HTTP reachability.

Trust Boundaries and Controls

  • observed — The route remains restricted to acting admins and retains its demo mutation restriction. The handler rejects the reserved builtin installation and environment-pinned versions before invoking the update service.

Resilience and Maintainability Implications

  • observed — Apply remains non-retryable: a lost response can follow a committed replacement. The endpoint contract directs callers to reread the installation rather than automatically retrying.
Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(plugins): guard the remaining installation writes on the package they read" matches the main change: the notify pass, UpdateToAvailableVersion, and the admin handler's ErrNoUpdateAvaila…
Linked Issues check Passed Directly linked issue #4518 lists four stale-write cases. Coverage at head 3a15117, from the previous assessment and the raw summary:

1. Archive repair [#4518 item 1]: #4602 is merged. ArchiveCach…
Out of Scope Changes check Passed The changed files map to objectives of #4518. internal/plugins/installation.go adds ErrNoUpdateAvailable. internal/plugins/service.go holds the version check and the removed second clear. internal/plu…
Description check Passed The description is specific and on-topic. It names the changed files and functions (notifyPluginUpdate, UpdateToAvailableVersion, ApplyAdminPluginUpdate, ErrNoUpdateAvailable, IfInstallPath), lists th…
Full details: Title check

Explanation

The title "fix(plugins): guard the remaining installation writes on the package they read" matches the main change: the notify pass, UpdateToAvailableVersion, and the admin handler's ErrNoUpdateAvailable mapping now guard installation writes on the package they read, so the title is fully related to the changeset. It is specific enough for a teammate scanning history. The title is 78 characters, which is within a reasonable single-line length.

Full details: Linked Issues check

Explanation

Directly linked issue #4518 lists four stale-write cases. Coverage at head 3a15117, from the previous assessment and the raw summary:

  1. Archive repair [#4518 item 1]: #4602 is merged. ArchiveCache.load persists through InstallationStore.repairArchive, which writes only while the archive row keeps the read updated_at and bytes. This PR drops its own archive change. This was not re-read in this pass.
  2. Notify offer [#4518 item 2]: notifyPluginUpdate sets IfInstallPath to the snapshot path on the available_version write. On ErrInstallationChanged the offer is dropped, and handleExistingPlugin reports no outcome. TestNotifyPluginUpdateDropsAnOfferForAReplacedReleaseDB covers the stale write.
  3. Second clear [#4518 item 3]: UpdateToAvailableVersion no longer clears available_version after the replacement. The install catalog test expects [update stop] for the applied-update case.
  4. Downgrade and 500 to 409 [#4518 items 2 and 4]: UpdateToAvailableVersion refuses a missing, empty, equal, or older offer with ErrNoUpdateAvailable. ApplyAdminPluginUpdate maps it to ErrPluginUpdateUnavailable, which apiv2 answers as 409 conflict.

Change since the previous reviewed head d2f8910: AutoUpdateService.Check now clears a notice whose offer is not newer than the installed version, and treats ErrInstallationChanged as no update in the notify path. This matches the stale-offer objective. The changed blob for internal/plugins/auto_update.go could not be read, so it is not confirmed that the new clear uses the same IfInstallPath guard as the withdrawn-notice clear, as the commit message states. That guard is unverified; the four items above rest on earlier evidence and the raw summary.

Full details: Out of Scope Changes check

Explanation

The changed files map to objectives of #4518. internal/plugins/installation.go adds ErrNoUpdateAvailable. internal/plugins/service.go holds the version check and the removed second clear. internal/plugins/auto_update.go holds the IfInstallPath guard on the notify write, the ErrInstallationChanged handling, and the stale-notice clear for non-newer offers. internal/api/handlers/admin_plugin_lifecycle.go maps the new error to the 409 path. The test files and scripts/ci/db-contracts.txt cover those changes. The stale-notice clear is a refinement of the stale-offer objective, not unrelated work. No unrelated feature, API, config, or schema change is described. The changed blobs could not be read, so this verdict relies on the summaries and the PR description.

Full details: Description check

Explanation

The description is specific and on-topic. It names the changed files and functions (notifyPluginUpdate, UpdateToAvailableVersion, ApplyAdminPluginUpdate, ErrNoUpdateAvailable, IfInstallPath), lists the three races it fixes, and describes the tests and validation. It matches the raw summary, so the description check passes.

Finishing Touches

Generate unit tests (beta)

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

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

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: 00a1a80b-df5f-4b61-aec4-406975b93168
Commits

Reviewing files that changed from the base of the PR and between 40c093c and 9ad806a.

Files selected for processing: 8

  • internal/api/handlers/admin_plugin_lifecycle.go
  • internal/plugins/archive_cache.go
  • internal/plugins/archive_cache_test.go
  • internal/plugins/auto_update.go
  • internal/plugins/installation.go
  • internal/plugins/service.go
  • internal/plugins/service_install_catalog_db_test.go
  • internal/plugins/update_offer_test.go

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

Comment thread internal/plugins/update_offer_test.go Resolved
@rangoDJ
rangoDJ force-pushed the fix/4518-guard-plugin-installation-writes branch from 9ad806a to a4838c1 Compare November 19, 2026 19:24
@silo-kody

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

rangoDJ and others added 2 commits November 19, 2026 20:39
…they read

holds the package it was prepared against. Four other writes still went
by installation ID alone, so they could undo or misreport a newer
install that landed after they read the row:

- Archive repair stored the repaired legacy archive with SaveArchive,
  which could put the old release's package back under a newer row. It
  now goes through Update with the archive and IfInstallPath, and drops
  the repair when another install changed the row.
- The notify pass recorded available_version by ID, so an offer decided
  against 1.0.0 could land after an admin installed 2.0.0. It is now
  guarded on the install path it read, and dropped when that changed.
- UpdateToAvailableVersion installed whatever version was recorded. It
  now refuses one that isn't newer than the installed version, and no
  longer clears available_version a second time after the replacement
  already cleared it in its own write, which could erase a newer offer.
- The refusal is ErrNoUpdateAvailable, which the admin handler answers
  as the existing 409 conflict instead of a 500.

Closes Silo-Server#4518

Co-Authored-By: Claude Opus 5.5 <[email protected]>
t.Context() is canceled before cleanup callbacks run, so the DELETE got a
canceled context and could leave the seeded installation behind. The
cleanup now uses a bounded context of its own and reports a failed
delete.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rangoDJ
rangoDJ force-pushed the fix/4518-guard-plugin-installation-writes branch from a4838c1 to 8de8c4d Compare November 20, 2026 01:49
@silo-kody

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

Comment thread internal/plugins/auto_update.go Outdated
Comment on lines +597 to +600
if errors.Is(err, ErrInstallationChanged) {
s.logger.InfoContext(ctx, "dropped stale plugin update offer: the plugin was replaced meanwhile",
"plugin_id", existing.PluginID, "available_version", newVersion)
return nil

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 high

Dropped stale offers are counted as recorded updates

When an installation is replaced during the check, handleExistingPlugin reports autoUpdateOutcomeNotified despite recording no offer, causing a false update report and cache invalidation. Propagate ErrInstallationChanged to the caller and map it to autoUpdateOutcomeNone.

Prompt for LLM
File internal/plugins/auto_update.go, lines 597-600:

Dropped stale offers are counted as recorded updates

When an installation is replaced during the check, returning nil causes `handleExistingPlugin` to report `autoUpdateOutcomeNotified` even though no offer was recorded; the task then incorrectly reports an available update and triggers cache invalidation. Propagate the stale-installation result to the caller and map it to `autoUpdateOutcomeNone`.

Suggested code:

if errors.Is(err, ErrInstallationChanged) {
		s.logger.InfoContext(ctx, "dropped stale plugin update offer: the plugin was replaced meanwhile",
			"plugin_id", existing.PluginID, "available_version", newVersion)
		return err
	}

Talk to Kody by mentioning @kody

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

​

​

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in d2f8910. notifyPluginUpdate now returns ErrInstallationChanged for a dropped offer, and handleExistingPlugin maps it to autoUpdateOutcomeNone, as the auto branch does. TestNotifyPluginUpdateDropsAnOfferForAReplacedReleaseDB now goes through handleExistingPlugin and checks the outcome: it failed before the fix with outcome 2 (notified) and passes now.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for the update. Returning ErrInstallationChanged and mapping it to autoUpdateOutcomeNone addresses the reported false notification. The expanded test also checks the caller’s outcome, which covers the gap in the original suggestion.

I haven’t independently verified the commit or test results.

notifyPluginUpdate dropped an offer whose installation was replaced
meanwhile but returned nil, so handleExistingPlugin reported it as
notified and the pass counted an available update it never recorded. It
now returns ErrInstallationChanged, which handleExistingPlugin maps to no
outcome, as the auto branch already does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-kody

silo-kody Bot commented Nov 20, 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 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.

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

Review of d2f8910. Three findings, each inline. I'm fixing all three in a commit on this branch, and a summary will follow once that commit is pushed.

Comment thread internal/plugins/service.go Resolved
Comment thread internal/plugins/update_offer_test.go Resolved
Comment thread internal/plugins/service.go Resolved
…led release

Applying such a notice is now refused with 409, so keeping it left web
admin an Update button that could never succeed. The update check clears
it under the same guards as a withdrawn notice. Run the notify-offer
Postgres test in CI, and restore the plain "no update available" text.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-kody

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

…-installation-writes

# Conflicts:
#	scripts/ci/db-contracts.txt

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

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: f30a327b-ada0-45ae-b325-5e7e91c73ad9
Commits

Reviewing files that changed from the base of the PR and between d2f8910 and 3a15117.

Files selected for processing: 4

  • internal/plugins/auto_update.go
  • internal/plugins/provision_package_test.go
  • internal/plugins/service.go
  • scripts/ci/db-contracts.txt
Files skipped from review as they are similar to previous changes: 1

  • internal/plugins/service.go

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

// than the installed release: applying that is refused, and a stale
// check recorded it before writes were fenced on the package (#4518).
if version := existing.AvailableVersion; version != nil && *version != "" &&
(snapshot.withdrawn(*existing.RepositoryID, existing.PluginID, *version) || compareVersions(*version, existing.Version) <= 0) {

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.

Minor · Data Integrity & Integration · Quick win

Guard the stale-notice clear on the offer it read.

The new predicate sends a non-withdrawn offer that is not newer than the installed release to the clear branch. The clear checks ifAvailableVersion only in memory, in matches. The row update in updateInstallationRow guards only IfVersion and IfInstallPath, and the installation row is not locked for the read.

A notify write that stores a newer offer after the read and before the clear can therefore be erased. The clear still matches the installed version and install path, so its update can set the notice to NULL.

Make the clear conditional on the offer it read. Either add an available_version predicate to the row update's WHERE clause, or lock the installation row across the read and the write. Either option keeps a newer offer. The effect is limited to the lost notice; the installation itself is not affected.

@Quick104

Copy link
Copy Markdown
Contributor

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

Review summary

Reviewed head: 10f5fab. That is the contributor's d2f8910, plus one review fix (3a15117) and a merge of main at 97ace34.

The approach holds up. It uses the existing IfInstallPath guard on the notify write, refuses a non-newer offer before anything downloads or stops, and drops the unguarded second clear. Every replacement gets a fresh install-* directory, so the path guard catches any reinstall, same-version ones included. Both replacement writers clear available_version in their own guarded transaction, so removing the second clear can't leave an applied offer behind.

Addressed findings

  • Stale offer never cleared (medium). A non-newer available_version was refused but kept, so web admin showed an Update button that always answered 409. The update check now clears it under the withdrawn-notice guards (3a15117). All three council members and two of the code-review finders raised this independently.
  • New Postgres test skipped in CI (low). TestNotifyPluginUpdateDropsAnOfferForAReplacedReleaseDB is now in scripts/ci/db-contracts.txt.
  • Error text (nit). It reads no update available for plugin "x" again.
  • Merging main produced a conflict in scripts/ci/db-contracts.txt, where main had added two plugin entries in the same place. The merge keeps all three entries.

Tests

  • On the base (with only the ErrNoUpdateAvailable variable added so the tests compile), all three of the PR's tests fail for the reasons the description gives. The new TestAutoUpdateClearsWithdrawnNoticeDB step fails on d2f8910.
  • On a freshly migrated Postgres, internal/plugins/..., internal/api/handlers and internal/apiv2 pass at the merged head.
  • Nothing was reproduced live, because each race needs two overlapping operations.

Left for maintainers

  • [bug] Two plugin update races report a server error instead of skipping #5237 tracks two races that predate this PR and give the same result on main. /update answers 500 when the repository is deleted between the handler's read and the service's read. An uninstall during a notify check is recorded as a failed check. The fix for the second touches a line this PR changes, so it follows this PR.
  • Not filed, because they are unconfirmed and the next check corrects them: an offer recorded while an applied update downloads is cleared by that update's replacement, and two overlapping checks on different API servers can leave the older of two newer offers. Neither can downgrade a plugin.

Validated features

Validation tasks: none is right. Plugin management #1224 (Server) and #1225 (Web admin) have passed cases C1 and C2, recorded on build 1669. Server C1 and web admin C1 cover plugin updates. The happy path (an offer newer than the installed release) is unchanged. What changes is that a stale offer now gets a 409 instead of a downgrade, and the check clears it. That is a minor change, not a regression. C2 in both tasks shares no code with this change.

User manual and clients

  • Manual: unaffected. The siloserver.org plugin pages cover provisioning and don't describe the notify Update button.
  • Other clients: N/A, as the description says. The 409 was already documented for this endpoint, no field or route changes, and jellycompat has no plugin update surface.

Council

One round on d2f8910, read-only, at medium effort:

Member Model Score
Sol gpt-6.2-sol 7/10
Opus claude-opus-5-5 8/10
Gemini gemini-4-neon 8/10

Every member's main finding was the stale offer, now fixed. The fix is the one-condition repair two of them proposed, so I didn't run a second round.

Verdict

Fit: 9/10 · Readiness: 9/10 — ready (assuming CI is green)

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

@Quick104
Quick104 merged commit 59a7981 into Silo-Server:main Nov 23, 2026
21 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Some plugin installation writes ignore a newer install of the same plugin

2 participants