Skip to content

fix(watchsync): send a list removal under the key the provider lists now - #4283

Merged
Quick104 merged 3 commits into
mainfrom
fix/watchsync-stale-provider-item-key
Nov 15, 2026
Merged

Quick104 merged 3 commits into
mainfrom
fix/watchsync-stale-provider-item-key

Conversation

@Quick104

@Quick104 Quick104 commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Closes #4271
Related issue: N/A
Validation tasks: none

Other clients: N/A (no client-visible change)

With watch-provider list sync on, a title removed from the watchlist or favorites in Silo could stay on the provider and come back in Silo on the next sync. That happened when the provider had started listing the title under a different key from the one Silo stored for it, for example after TMDB moved the title to a new ID. This change sends the removal under the key the provider lists now.

A scheduled removal sends the provider only the stored provider key. The Simkl and MDBList plugins then send the provider the single ID in that key. Simkl reports every title it sent as applied, so a removal that missed the entry still cleared the pending removal in Silo. The provider kept listing the title, and the next import added it back.

The issue's own steps don't hit this: when a complete read sees the new key, it writes a second title row under that key, and that row's removal reaches the provider. The stored key goes stale only when nothing records the listing:

  • A title row whose local removal is already pending when the provider first lists the title under a new key, on a complete or an incremental read. The listing waits on the removal, so no row records the new key.
  • A library item that took over a title row at promotion (fix(watchsync): keep a watchlist title's IDs so sync follows it through promotion #4248), listed under a key that matches no single library item.
  • A library item whose local removal is pending, matched by an older listing under another key. The import skips that listing, and the complete read then marked the removal done without sending it.

Approach

The complete read's record of what the provider listed now keeps, for each key and ID, the key of the listing that carried it. When the missing-row check keeps a row because the provider lists the title under another of its IDs, the row takes that listing's key. When the import skips a listing because a pending removal will take it off (a library item's or a title row's), that row takes the listing's key too, on any read.

The key changes through a new single-column repository update, SetListItemProviderKey. The existing upsert also writes local_present and last_error from the row as read, so it could undo a local removal recorded during the sync.

The presence record moved to its own file because lists.go is at its line limit. No plugin, contract, or schema changes.

Validation

  • Focused service tests: two existing watchlist tests gained a check on the row's key (one now runs over a complete and an incremental read), and the favorites pending-removal table gained a case for an older listing under another key. Each failed on the base for this reason (the row kept tmdb:550, tmdb:1399, and tmdb:549) and passes on this branch.
  • Repository update against Postgres: a throwaway (uncommitted) test against a disposable database migrated to this branch showed a row marked locally removed keeps local_present = false after its key moves, and its pending removal lists the new key. The existing list-item database tests pass there.
  • go build ./..., gofmt, go mod tidy -diff, go vet ./..., make lint-changed, make lint-router-recovery, make verify-local-paths, and make verify-size-ratchet pass. make test-go passes except four packages that fail on the macOS build host (case-insensitive file system, local FFmpeg build); none of them depends on internal/watchsync.
  • Not reproduced against a live provider: that needs a Simkl or MDBList entry that changes IDs.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/issue-4271/

Risks

No migration or contract change. More rows can now share a provider key. The existing hold on a shared key applies only when the other row is a library item still on the list, so a title row with the same key doesn't hold back a removal.

Follow-ups: none. The user manual already says watchlist and favorite removals reach the provider, so it needs no 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, running in T3 Code
  • Tool(s): Claude Code; T3 Code delegated review tasks (Codex for gpt-6.1-sol)
  • Model(s): claude-opus-5-5 (implementation and the plan cut review); gpt-6.1-sol (plan attack review)
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: before implementation, gpt-6.1-sol attacked the plan and claude-opus-5-5 cut it. The cut removed handling for an ID listed under several keys, a duplicate presence method, and a second write site. The attack found the pending library-item case, now covered here. Its other points (export restoring a library-derived key, concurrent runs, write failures mid-reconcile) describe behavior the base already has, and this change doesn't make them worse. A simplify pass ran on the change. The background adversarial review (gpt-6.1-sol) found nothing in two rounds: 35b0010, then 019e47d. The second round covered 7760b51, which fixes Kody's incremental-read finding and adds its test case, and the merge of main that takes in fix(watchsync): keep a removed watchlist title off when the library gains or loses it #4284, after which both pending-removal key moves sit in its shared waitsForListRemoval. Kody's other findings and CodeRabbit's were answered without changes.

🤖 Generated with Claude Code

A complete provider read could find a list row only through another of its
title's IDs and keep the row, but leave its provider key as it was. A removal
sends only that key, and the Simkl and MDBList plugins send the provider the
one ID it holds, so a removal under the old key could miss the provider's
entry; Simkl reports it applied, and the next sync added the title back.

The row now takes the key of the listing that kept it: a watchlist title row
or a promoted library item kept through another title ID, and a library item
whose pending local removal holds an older listing under another key. The key
changes through a single-column update, so a local removal written meanwhile
stays.

Closes #4271

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@silo-triage silo-triage Bot added the size/M 50–199 added + deleted lines (all files); change volume, not priority. label Nov 15, 2026
@silo-kody

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

@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T05:11:32.559265Z 019e47d New commits
🔒 Security Review ✅ Completed 2026-11-15T05:15:26.553704Z 019e47d New commits
ℹ️ 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 bug Something isn't working go Pull requests that update go code priority: P2 Limited scope, workaround exists, or polish labels Nov 15, 2026
@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

Watchlist sync now stores the provider key from a listing when it retains an item found under another known title ID. Pending-removal paths also update the key before skipping a re-addition.

Changes: Watchlist provider key updates

Layer / File(s) Summary
Complete-read key reconciliation
internal/watchsync/list_presence.go, internal/watchsync/lists.go, internal/watchsync/repository.go, internal/watchsync/list_titles_test.go
Complete-list reconciliation associates listed IDs with provider keys and updates a retained item’s key when it is found under another known ID. Tests verify the promoted show remains present and adopts the listing key.
Pending-removal key updates
internal/watchsync/list_titles.go, internal/watchsync/lists.go, internal/watchsync/list_titles_test.go, internal/watchsync/service_test.go, docs/architecture/watch-provider-plugins.md
Pending-removal paths store a nonempty listing key before waiting or skipping re-addition. Tests check that the local removal remains in effect and the pending row adopts the new key. The documentation describes the key update and how removals use the stored key.

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

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: crowquillx, blurbery

Merge Risk: Moderate · up to 7760b

The change makes watchlist sync store the key a provider currently lists a title under, so later removals reach the provider's entry. One case is still missed: a promoted library series whose stored key is an alias the provider also lists. That row keeps its old key, and a later removal may not remove the provider entry. Resolve this case before merging.

Security architecture risk: Minimal · up to 7760b

The change aligns removals with the identifier currently listed by the provider while preserving local removal state. The inspected changes establish no introduced or worsened risk to security, ownership or failure containment.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • observed — The changed write targets one list-item row within a selected connection and list kind. A listing-controlled key influences the remote item targeted by removal, but does not supply the connection selector. Provider removal receives the existing connection and configuration.

Trust Boundaries and Controls

  • observed — Scheduled removals remain gated by connection settings and provider capabilities. Their database selection excludes keys held by another locally present library item of the same kind, connection and list. The new key update does not bypass these checks or modify presence flags.

Resilience and Maintainability Implications

  • observed — Sync execution has an existing per-connection in-process mutex. Admission locks do not span provider work and explicitly permit overlapping scheduled runs across processes. Asynchronous local-list events use a separate path; the new column-specific write preserves presence changes made through that path.
Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the fix and its target: a watchsync list removal is now sent under the key the provider currently lists. This matches the changeset, which updates stored provider keys from the current…
Linked Issues check Passed Directly linked issue #4271 has one coding requirement. When a complete read finds a watchlist row only through another of the title's IDs, the row must take the provider key that the listing now uses…
Out of Scope Changes check Passed The changes stay within the stale-provider-key concern of #4271. Changes by file: (1) list_presence.go receives remoteListPresence, moved from lists.go. The PR states this move is needed because lis…
Description check Passed The description is specific and related to the changeset. It explains that watch-provider list sync can leave a removed title on the provider when the provider lists it under a different key than the …
Full details: Title check

Explanation

The title names the fix and its target: a watchsync list removal is now sent under the key the provider currently lists. This matches the changeset, which updates stored provider keys from the current listing before removals are sent. It is specific and does not use vague terms.

Full details: Linked Issues check

Explanation

Directly linked issue #4271 has one coding requirement. When a complete read finds a watchlist row only through another of the title's IDs, the row must take the provider key that the listing now uses. The change implements this. reconcileMissingRemoteListItems in internal/watchsync/lists.go now calls the new Repository.SetListItemProviderKey to store the listing's key before it retains the row. The remoteListPresence map in list_presence.go records the key that carried each ID and kind. listedKey and listedKeyForAny find that key. The issue's promoted-library-item case (#4248) is covered by the same missing-row path, and list_titles_test.go checks the promoted show's key. The repository update sets only provider_item_key and updated_at, so a local removal recorded in the same sync is not overwritten. The PR also covers pending-removal cases in importList and waitsForListTitleRemoval. These extend the same stale-key requirement and are disclosed in the PR description. Tests cover complete and incremental reads. Evidence is taken from the PR summary and the stated diff structure; I did not read the full diff, so per-line behavior rests on that summary.

Full details: Out of Scope Changes check

Explanation

The changes stay within the stale-provider-key concern of #4271. Changes by file: (1) list_presence.go receives remoteListPresence, moved from lists.go. The PR states this move is needed because lists.go is at its line limit. It is a relocation, not a behavior change. (2) repository.go adds SetListItemProviderKey to the interface and to PostgresRepository. This is the single-column update required by the key fix. (3) lists.go, list_titles.go, and their tests change how the provider key is stored in the three stale-key paths. Those paths are the missing-row check, the pending-removal skip on import, and the pending title-row wait. The PR description ties each path to a stale key that later sends a removal under an old key. (4) The architecture doc gains six lines that describe the new key update. This documents the change. No plugin, contract, or schema changes appear in the summary. The broader scope (incremental reads and pending removals) goes beyond the issue's single reproduction scenario. It remains the same root cause, and the PR description discloses it.

Full details: Description check

Explanation

The description is specific and related to the changeset. It explains that watch-provider list sync can leave a removed title on the provider when the provider lists it under a different key than the one Silo stored. It describes the fix: the complete read records each listing's key, a kept row takes the listing's key, and a new SetListItemProviderKey repository update changes only the key. It also names the affected files, the validation performed, and the risks. This matches the changes in the raw summary, including the list_presence.go file, the repository.go method, and the list_titles and lists.go updates.

Finishing Touches

Generate unit tests (beta)

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

Comment thread internal/watchsync/list_presence.go Resolved
Comment thread internal/watchsync/lists.go Resolved
A listing that waits on a pending title removal now moves that removal to
the listing's key when it is read, so an incremental read, which skips the
complete read's missing-row check, no longer leaves it under the old key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@silo-triage silo-triage Bot added the size/L 200–499 added + deleted lines (all files); change volume, not priority. label Nov 15, 2026
@silo-kody

silo-kody Bot commented Nov 15, 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 removed the size/M 50–199 added + deleted lines (all files); change volume, not priority. label Nov 15, 2026
Comment thread internal/watchsync/list_titles.go Resolved
Comment thread internal/watchsync/list_titles.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.

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

Major · Update a retained row to the listing key when its stored alias is listed. · lists.go:545

internal/watchsync/lists.go:545
Major · Data Integrity & Integration · Quick win

Update a retained row to the listing key when its stored alias is listed.

When a promoted series row stores an alias such as imdb:tt0944947, and the provider lists the title as tvdb:121361 with that IMDb ID, the stored key counts as listed. The filter at internal/watchsync/lists.go:545 then excludes the row from the missing set. The alternate-ID key update at lines 562-565 never runs for it.

When the matcher returns nil and LibraryHas returns true, importListTitle returns a nil state. trackListTitle then skips the upsert, so the listing key is not written on this path either.

The row keeps the old alias key after a complete read, although the provider still lists the title. A later local removal then sends the stale key. That key can fail to reach the provider's entry. Resolve the listing key for retained rows, including rows whose stored key appears among the listing's IDs.

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: b2519eac-0f40-4985-a3ae-3e74f23db792
Commits

Reviewing files that changed from the base of the PR and between 1452ea2 and 7760b51.

Files selected for processing: 7

  • docs/architecture/watch-provider-plugins.md
  • internal/watchsync/list_presence.go
  • internal/watchsync/list_titles.go
  • internal/watchsync/list_titles_test.go
  • internal/watchsync/lists.go
  • internal/watchsync/repository.go
  • internal/watchsync/service_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.

@Quick104

Copy link
Copy Markdown
Contributor Author

On CodeRabbit's outside-diff finding at lists.go:545 (retained row whose stored alias is listed): no change. The stored key counts as listed only when the provider's listing still carries that ID. In the example, the provider lists the series as tvdb:121361 with IMDb tt0944947, so a removal sent as imdb:tt0944947 names an ID the provider's entry still has, and the plugin's removal finds it. This PR moves a key only when the provider no longer reports the stored ID, which is when a removal could miss. Kody raised the same case and withdrew it.

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

…rovider-item-key

# Conflicts:
#	internal/watchsync/list_titles.go
#	internal/watchsync/lists.go
@Quick104
Quick104 merged commit f3b296f into main Nov 15, 2026
17 checks passed
@Quick104
Quick104 deleted the fix/watchsync-stale-provider-item-key branch November 15, 2026 05:23
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/L 200–499 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Watchlist sync keeps an old provider key after the provider lists the title under another ID

1 participant