Repository navigation
Description
What happened
Context: same setup as #2819. Plex and Silo side by side, with two-way sync through CrossWatch on the Jellyfin-compatible API.
Each POST /UserItems/{id}/UserData with "Played": true adds a row to user_watch_history, including when the item is already played with the same date. (A repeated POST /UserPlayedItems/{id} leaves one row.)
CrossWatch writes every watched item as POST /UserPlayedItems/{id}?DatePlayed=… followed by a UserData post with "Played": true and the same LastPlayedDate. After its first sync of 11,857 items, user_watch_history held two rows for each of them, 23,714 in all, all with source = jellycompat. In every one of the 11,857 pairs, both rows have the same watched_at. What shows as watched is correct, but anything that counts history rows sees each of those plays twice.
Each sequence below ran on one unplayed movie and one unplayed episode (A = 2019-03-14T20:15:00Z, B = 2020-08-02T18:30:00Z):
| Sequence | History rows (movie, episode) |
|---|---|
UserPlayedItems (A), then UserData Played (A) |
2, 2 |
UserData Played (A), twice |
2, 2 |
UserPlayedItems with no date, then UserData Played with no date |
2, 2 |
UserPlayedItems (A), twice |
1, 1 |
UserPlayedItems (A), then UserPlayedItems (B) |
1, 1 (keeps A) |
Steps to reproduce
Starting point: an unplayed movie, and an unscoped API key (sa_…) owned by the admin account.
POST /UserItems/<item-id>/UserData?userId=<user-id>with body{"Played":true,"PlaybackPositionTicks":0,"LastPlayedDate":"2019-03-14T20:15:00Z"}returns 200.user_watch_historyhas 1 row for the item.- Send the same request again. It returns 200, and
user_watch_historyhas 2 rows for the item, both withwatched_at=2019-03-14 20:15:00+00. DELETE /UserPlayedItems/<item-id>?userId=<user-id>to clean up.
Expected behavior
A UserData post sets the item's user data and doesn't record a new play. In Jellyfin, POST /UserItems/{id}/UserData only overwrites the fields it's given on the single stored user-data row (UserDataManager.SaveUserData in Emby.Server.Implementations/Library/UserDataManager.cs). Plays are counted only by marking played: BaseItem.MarkPlayed increments PlayCount when a date is passed. (Read from source at jellyfin 08c2ba6, not tested against a Jellyfin server.) Clients that post user data to confirm or restore state, like CrossWatch here, expect that post to be harmless.
Silo version / commit
1302 · 50108f6 (image ghcr.io/silo-server/silo-server:build-1302)
Deployment
Unraid
Area
Jellyfin-compatible clients
Clients affected
- Jellyfin-compat client (Infuse, Findroid, ...)
Client app and device
CrossWatch 0.13.6, plus direct HTTP requests for the reproduction
Relevant logs
Steps 1 and 2 as run. Both requests returned 200. No warnings or errors were logged for them. The only warnings in that minute were unrelated catalog person merge messages from the library scan. Raw lines, redactions marked:
time=2026-10-21T18:39:17.004-04:00 level=INFO msg="jellycompat request" component=jellycompat request_id=<host, redacted>/astJKp24lG-025550 method=POST path=/UserItems/<item-id, redacted>/UserData original_path=/UserItems/<item-id, redacted>/UserData query="userId=<user-id, redacted>" route=/UserItems/{itemId}/UserData status=200 duration_ms=36 remote_addr=<redacted> user_agent=Python-urllib/3.13 content_length=86 auth_kind=mediabrowser
time=2026-10-21T18:39:17.872-04:00 level=INFO msg="jellycompat request" component=jellycompat request_id=<host, redacted>/astJKp24lG-025555 method=POST path=/UserItems/<item-id, redacted>/UserData original_path=/UserItems/<item-id, redacted>/UserData query="userId=<user-id, redacted>" route=/UserItems/{itemId}/UserData status=200 duration_ms=21 remote_addr=<redacted> user_agent=Python-urllib/3.13 content_length=86 auth_kind=mediabrowserTechnical notes
State of user_watch_history after CrossWatch's sync and my tests. The single-row item and the import row are one play recorded by Silo's own Plex webhook sync.
select n, count(*) from (select media_item_id, count(*) n from user_watch_history group by 1) s group by 1;
-- 2 | 11857
-- 1 | 1
select source, completed, count(*) from user_watch_history group by 1,2;
-- jellycompat | t | 23714
-- import | t | 1
select count(*) from (select media_item_id from user_watch_history group by 1 having count(*)=2 and min(watched_at)<>max(watched_at)) s;
-- 0Suspected cause, from the source at 50108f6:
- The
UserDatapath never checks for an existing completed row. The handler (internal/jellycompat/userdata_direct.go) callsRecordJellycompatProgress(internal/watchstate/service.go:674). That leads toApplyJellycompatProgress(internal/userstore/pgstore/jellycompat_progress.go:46), which callsaddVisibleHistory(internal/userstore/pgstore/progress.go:1172) whenever the edit carries a history entry, soPlayed: trueinserts a new row every time. - The
UserPlayedItemspath does check.MarkPlayedBatchAtgoes throughmarkWatchedBatchTx(progress.go:365). Its progress upsert only appliesWHERE NOT user_watch_progress.completed(or when the row is hidden;progress.go:487), and history is inserted only for the rows that upsert returns. That also explains the last table row, where a second mark with date B keeps A.
The CrossWatch calls are _mark_played followed by _normalize_watched in providers/sync/jellyfin/_history.py (called at :1052 and :1064).
AI harness
Claude Code (CLI)
AI tool(s)
Claude Code: shell over SSH to run the requests and SQL on my deployment; read-only reading of silo-server, CrossWatch and Jellyfin source; a separate Claude Code agent for the review below
AI model(s)
claude-opus-5-5[1m]
AI involvement
Fully AI-generated, human verified
Independent or adversarial review
A separate Claude Code agent (claude-opus-5-5) reviewed the drafts read-only. It checked every number, table cell, quoted log line and code reference against the raw test outputs, SQL output, Silo request log and the silo-server (50108f6, 9cc740a) and CrossWatch source.
It found:
- log lines cut short without a mark, and one line missing from the log extract it was given;
- claims scoped wider than the data (an hour-wide time check, the makeup of the 12-item test, "library lists" when only
Filters=IsPlayedwas tested); - a cause inferred for CrossWatch's behaviour rather than observed;
- for both issues, the precise code path, where the drafts had pointed at a shared line.
Resolution:
- the log lines were replaced with complete lines taken from the unfiltered log;
- the time window was re-measured against CrossWatch's logged writes, and lists without the filter were tested;
- scope and counts were corrected, inferred claims were moved to Technical notes and hedged;
- I checked the cited code paths myself before including them.
Confirmations
- I searched open and recently closed issues and pull requests, and this is not already reported
- I reproduced this myself on a real deployment
- Any logs provided are raw apart from marked redactions and are not AI-summarized; if none were available, I said so above
Activity
7487 commentedon Oct 22, 2026
I reproduced this through the compatibility handler and am preparing a focused fix that keeps UserData state updates but leaves played-history creation to the dedicated mark-played route.