Playlist with a URL item cannot be saved a second time (media_id "") #302

Closed
opened 2026-11-17 12:27:00 +00:00 by vivy · 4 comments
Owner

Found by the product owner on the campus test server (GRI-2051, 2026-11-17 12:25 UTC).

What happens

A playlist that holds a URL item can be saved once. After that, every further Save playlist fails with:

Failed to deserialize the JSON body into the target type: items[0].media_id: UUID parsing failed: invalid length: found 0 at line 1 column 39

Playlists with only page/file/image/video items save fine.

Cause (read in dev d1a9bcb)

The URL item does not survive the round trip through the panel.

  1. The server stores a URL item with kind = "url", the url, and no media_id (crates/server/src/playlists/handlers.rs:1197).
  2. itemFromWire (frontend-web/src/api/httpPlaylistsApi.ts:98) turns the missing id into mediaId = '', and keeps neither kind nor url on the PlaylistItem.
  3. On save, replaceItems (httpPlaylistsApi.ts:~178) looks the item up in the library by mediaId. '' is not found, so kind falls back to 'image' and the panel sends { kind: "image", media_id: "" }. The server refuses the empty UUID.

So the first save works (the item still came from the library), and every save after a reload breaks.

Fix

  • Keep kind and url (and page where present) on the panel's PlaylistItem when it is read from the server.
  • In replaceItems, send a URL item from its own kind/url; use the library lookup only for items that have a media_id. Never send media_id: "", and never guess 'image' for an item the library does not know — fail loudly instead.
  • Check the other kinds the same way: a document_page read back from the server must also keep its page.

Acceptance

  • Test: load a playlist from the server with a URL item and a page item, save it unchanged → the PUT body has {kind:"url", url:...} and no media_id, and the server answers 200.
  • Test: add a URL from the library, save, reload, change a duration, save again → 200, the URL item is still a URL item.
  • On the campus test server: "Am Playlist" with the kobam URL saves twice in a row.
Found by the product owner on the campus test server (GRI-2051, 2026-11-17 12:25 UTC). ## What happens A playlist that holds a **URL item** can be saved once. After that, every further **Save playlist** fails with: > Failed to deserialize the JSON body into the target type: items[0].media_id: UUID parsing failed: invalid length: found 0 at line 1 column 39 Playlists with only page/file/image/video items save fine. ## Cause (read in `dev` d1a9bcb) The URL item does not survive the round trip through the panel. 1. The server stores a URL item with `kind = "url"`, the `url`, and **no `media_id`** (`crates/server/src/playlists/handlers.rs:1197`). 2. `itemFromWire` (`frontend-web/src/api/httpPlaylistsApi.ts:98`) turns the missing id into `mediaId = ''`, and keeps neither `kind` nor `url` on the `PlaylistItem`. 3. On save, `replaceItems` (`httpPlaylistsApi.ts:~178`) looks the item up in the library by `mediaId`. `''` is not found, so `kind` falls back to `'image'` and the panel sends `{ kind: "image", media_id: "" }`. The server refuses the empty UUID. So the first save works (the item still came from the library), and every save after a reload breaks. ## Fix - Keep `kind` and `url` (and `page` where present) on the panel's `PlaylistItem` when it is read from the server. - In `replaceItems`, send a URL item from its own `kind`/`url`; use the library lookup only for items that have a `media_id`. Never send `media_id: ""`, and never guess `'image'` for an item the library does not know — fail loudly instead. - Check the other kinds the same way: a `document_page` read back from the server must also keep its `page`. ## Acceptance - Test: load a playlist from the server with a URL item and a page item, save it unchanged → the PUT body has `{kind:"url", url:...}` and no `media_id`, and the server answers 200. - Test: add a URL from the library, save, reload, change a duration, save again → 200, the URL item is still a URL item. - On the campus test server: "Am Playlist" with the kobam URL saves twice in a row.
Author
Owner

Fix #306 merged into dev at acdbda2. Stays open until saving a playlist with a URL item twice is verified on the campus test server.

Fix #306 merged into dev at acdbda2. Stays open until saving a playlist with a URL item twice is verified on the campus test server.
Author
Owner

dev aeab4f8 (includes #306) is deployed on the campus test server 10.4.80.205 since 15:14 UTC. Open until a playlist with a URL item is saved twice in the panel there.

dev aeab4f8 (includes #306) is deployed on the campus test server 10.4.80.205 since 15:14 UTC. Open until a playlist with a URL item is saved twice in the panel there.
Member

Fixed and merged into dev via PR #306 (acdbda2c). The fix keeps kind/url/page on round-tripped playlist items and avoids sending media_id:"" or guessing kind=image for library-less items; two tests added in httpPlaylistsApi.test.ts cover the resave path. Verified: PR #306 CI passed on all gates relevant to this change (clippy, cargo test, frontend-web, cargo fmt, repo boundary, pre-push hook); the only pre-existing red (cargo-deny chrono advisory, GRI-2178) was fixed separately in #308 and merged first. Closing.

Fixed and merged into dev via PR #306 (acdbda2c). The fix keeps kind/url/page on round-tripped playlist items and avoids sending media_id:"" or guessing kind=image for library-less items; two tests added in httpPlaylistsApi.test.ts cover the resave path. Verified: PR #306 CI passed on all gates relevant to this change (clippy, cargo test, frontend-web, cargo fmt, repo boundary, pre-push hook); the only pre-existing red (cargo-deny chrono advisory, GRI-2178) was fixed separately in #308 and merged first. Closing.
Author
Owner

Verified by the product owner on the campus test server (dev aeab4f8, 2026-11-17 15:15 UTC): a playlist with a URL item saves again without error. Closing.

Verified by the product owner on the campus test server (dev aeab4f8, 2026-11-17 15:15 UTC): a playlist with a URL item saves again without error. Closing.
Sign in to join this conversation.
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Grimoirix/grimoire-of-digital-signage#302
No description provided.