Repository navigation
fix(watchsync): sync favorites and watchlists when two items share a provider key - #2467
Conversation
…provider key watch_provider_list_items allowed one row per provider key, but the key (an IMDb, TMDB, or TVDB id without its kind) is not unique across library items. A list holding two such items failed every sync with a duplicate key error before anything was sent. Make the key index non-unique, as on the ratings and dropped-show tables, and handle several items per key: a removal stays held while another item of the same kind still on the local list has the key, an import does not add back an item whose removal is still pending, and a remote tombstone removes every row with its key unless the rows name more than one kind of title. Closes #2466 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: 🟡 Moderate · up to
|
…r adds A full import now counts each IMDb, TMDB, and TVDB id on a provider row as present, because a plugin's key can use a different id than the one stored at export (Trakt keys shows by TVDB id first). Otherwise an ambiguous match on two copies of a series removed both locally. An import skips re-adding an item with a pending local removal only when the provider's listing is not newer than the removal, so a title re-added on the provider after a failed removal is imported instead of removed again. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1c2ca9cd44
ℹ️ 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".
A full import records each listed key with the kind of title the provider row names, so a movie row no longer keeps a series with the same TMDB id. A row or stored item without a kind still matches any kind. Plugins that omit listed_at get the import time; RemoteFavorite now marks that time as guessed, and an import never treats a guessed listing as newer than a pending local removal. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ds after tombstones The migration now runs without a transaction, builds the non-unique key index concurrently under a new name, and drops the unique one concurrently, so list syncs keep reading and writing the table while it runs. Down restores the unique index the same way. A tombstone in an incremental read clears the pending local removal of the rows it unlists, so a later row in the same read that lists the item again counts as a new add. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 548549f65f
ℹ️ 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".
…ilds it An interrupted Down can leave the concurrently built unique index invalid, and IF NOT EXISTS would then skip rebuilding it on retry. Drop it concurrently first, as Up does for its own index. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolves the conflicts with main's list sync change (#2467), which now removes every copy of a title that shares a provider key: a removal is still counted once the local list changes, before the bookkeeping write. TasteSeed returns to the renamed Personalize settings page (#2398). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Problem
Closes #2466
Related issue: N/A
Validation tasks: none
Favorites and watchlist sync with Trakt, Simkl, or MDBList fails on every run when two library items share a provider key: the connection shows
favorites export: upsert list item state: ... duplicate key value violates unique constraint "idx_watch_provider_list_items_provider_key", and nothing on the list reaches the provider. A user hit this right after importing favorites from Emby. This change lets each library item keep its own sync row and handles the shared key on import, export, and removal.The sync row's key is the item's IMDb id, else TMDB, else TVDB id, with no kind.
media_itemsdoes not keep those ids unique, so two items for one title, or a movie and a series with the same TMDB id and no IMDb id, produce one key. The unique index on(connection_id, list_kind, provider_item_key)rejected the second row, and the error stopped the run.Approach
A new migration replaces the unique key index with a plain one, building and dropping both concurrently so syncs keep running. Rows stay unique per library item, as the ratings and dropped-show sync rows already are.
The list sync now handles several items per key:
docs/architecture/watch-provider-plugins.mdrecords these rules. Only the server's watch-sync code changes; there is no API, client, or jellycompat change.Validation
main: a focused database test that writes two rows with one key fails with the same message. A full sync could not run there because no watch-provider plugin was connected.go build ./...,gofmt,go vet ./...,make lint-changed,make migrate-validate,make verify-migration-ledger, andmake verify-local-pathspass.make test-gopasses apart from two real-FFmpeg tests ininternal/mediasample, which fail the same way onmainwith the FFmpeg 6.1 installed on the test machine. No web files changed, so the web gate was not run.Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/issue-2466/
Risks
Checklist
AI Disclosure
🤖 Generated with Claude Code
Note
Fix favorites and watchlist sync when two items share a provider key
watch_provider_list_items, tracked by key and title kind.ListListItemsWithSharedKeyHeldmethod to satisfywatchsync.Repositoryin repository.go.Macroscope summarized b2000e1.