GRI-2109: return 409 on playlist delete with devices assigned, offer unassign #246

Merged
vivy merged 3 commits from fix/GRI-2109-playlist-delete-device-conflict into dev 2026-11-15 19:19:30 +00:00
Member

Closes #223

Deleting a playlist that devices use failed with a bare 500: the handler
passed the DB foreign-key violation through unchanged.

DELETE /playlists/{id} now:

  • returns 409 device_assigned naming the blocking devices (id, name)
    when any device is assigned the playlist;
  • with ?unassign_devices=true, unassigns those devices (pushing
    PlaylistCleared, or marking pending-clear if offline — same as
    DELETE /devices/{device_id}/playlist) and deletes the playlist, in one
    transaction.

Same shape as the campus-delete (#207) and media-in-use precedents.

No QA-authored tests existed for this issue, so I wrote integration tests in
crates/server/tests/playlist_integration.rs covering a playlist with
assigned devices, both online and offline, plus the plain-conflict and
success paths.

Test plan

  • ./scripts/local-gates.sh --rust-only — every gate passed locally.
  • CI gates on this PR.
Closes https://git.grimoirix.org/Grimoirix/grimoire-of-digital-signage/issues/223 Deleting a playlist that devices use failed with a bare 500: the handler passed the DB foreign-key violation through unchanged. `DELETE /playlists/{id}` now: - returns `409 device_assigned` naming the blocking devices (`id`, `name`) when any device is assigned the playlist; - with `?unassign_devices=true`, unassigns those devices (pushing `PlaylistCleared`, or marking pending-clear if offline — same as `DELETE /devices/{device_id}/playlist`) and deletes the playlist, in one transaction. Same shape as the campus-delete (#207) and media-in-use precedents. No QA-authored tests existed for this issue, so I wrote integration tests in `crates/server/tests/playlist_integration.rs` covering a playlist with assigned devices, both online and offline, plus the plain-conflict and success paths. ## Test plan - `./scripts/local-gates.sh --rust-only` — every gate passed locally. - CI gates on this PR.
GRI-2109: return 409 device_assigned on playlist delete, with unassign_devices option
All checks were successful
CI / the pre-push hook (pull_request) Successful in 4s
CI / install.sh client upgrade (pull_request) Successful in 6s
CI / cargo fmt (pull_request) Successful in 4s
CI / cargo deny (pull_request) Successful in 15s
CI / cargo deny advisories (pull_request) Successful in 18s
CI / repository boundary (pull_request) Successful in 6s
CI / cargo clippy (pull_request) Successful in 1m21s
CI / frontend-web (pull_request) Successful in 1m5s
CI / cargo test (pull_request) Successful in 2m28s
CI / Notify gate failed (pull_request) Has been skipped
CI / CI (pull_request) Successful in 2s
5f17186348
Deleting a playlist that devices use failed with a bare 500 from the
foreign-key violation. DELETE /playlists/{id} now returns 409 with the
blocking devices named; ?unassign_devices=true unassigns them (pushing
PlaylistCleared, or marking pending-clear if offline) and deletes the
playlist in one transaction.
vivy approved these changes 2026-11-15 18:28:14 +00:00
vivy left a comment

Approved. 409 now names the devices, and ?unassign_devices=true unassigns and deletes in one transaction, with PlaylistCleared pushed or marked pending for each device. Tests cover online, offline, none and unknown.

One small point, not blocking: in delete_unassigning_devices the SELECT of assigned devices and the DELETE of assignments are two statements under READ COMMITTED. A device assigned between them is unassigned but gets no PlaylistCleared. DELETE FROM device_playlist_assignments ... RETURNING device_id joined to devices would close that. Fine as a follow-up comment on the issue.

Approved. 409 now names the devices, and ?unassign_devices=true unassigns and deletes in one transaction, with PlaylistCleared pushed or marked pending for each device. Tests cover online, offline, none and unknown. One small point, not blocking: in delete_unassigning_devices the SELECT of assigned devices and the DELETE of assignments are two statements under READ COMMITTED. A device assigned between them is unassigned but gets no PlaylistCleared. `DELETE FROM device_playlist_assignments ... RETURNING device_id` joined to devices would close that. Fine as a follow-up comment on the issue.
Merge remote-tracking branch 'origin/dev' into fix/GRI-2109-playlist-delete-device-conflict
All checks were successful
CI / the pre-push hook (pull_request) Successful in 5s
CI / install.sh client upgrade (pull_request) Successful in 12s
CI / cargo fmt (pull_request) Successful in 7s
CI / cargo deny (pull_request) Successful in 24s
CI / cargo deny advisories (pull_request) Successful in 27s
CI / cargo clippy (pull_request) Successful in 1m54s
CI / repository boundary (pull_request) Successful in 4s
CI / frontend-web (pull_request) Successful in 1m15s
CI / cargo test (pull_request) Successful in 3m15s
CI / Notify gate failed (pull_request) Has been skipped
CI / CI (pull_request) Successful in 2s
53b8eebd84
Merge branch 'dev' into fix/GRI-2109-playlist-delete-device-conflict
All checks were successful
CI / the pre-push hook (pull_request) Successful in 5s
CI / install.sh client upgrade (pull_request) Successful in 10s
CI / cargo fmt (pull_request) Successful in 5s
CI / cargo deny (pull_request) Successful in 19s
CI / cargo deny advisories (pull_request) Successful in 23s
CI / cargo clippy (pull_request) Successful in 1m27s
CI / repository boundary (pull_request) Successful in 4s
CI / frontend-web (pull_request) Successful in 57s
CI / cargo test (pull_request) Successful in 3m7s
CI / Notify gate failed (pull_request) Has been skipped
CI / CI (pull_request) Successful in 1s
ef87086025
Author
Member

CI is green on ef87086 (CTO merged dev into this branch again after approving 5f17186 — the new tip only pulls in unrelated dev changes: CI workflow, install.sh, deployment docs, a kiosk install test script. No playlist-delete logic changed since the approved commit). All CI gates pass: clippy, deny, deny-advisories, fmt, cargo test, frontend-web, install.sh client upgrade, repository boundary, pre-push hook. Local working tree fast-forwarded to match. The existing approval (review #472) is marked stale against the new head, so this is ready for re-approval/merge into dev whenever convenient.

CI is green on `ef87086` (CTO merged `dev` into this branch again after approving `5f17186` — the new tip only pulls in unrelated dev changes: CI workflow, install.sh, deployment docs, a kiosk install test script. No playlist-delete logic changed since the approved commit). All CI gates pass: clippy, deny, deny-advisories, fmt, cargo test, frontend-web, install.sh client upgrade, repository boundary, pre-push hook. Local working tree fast-forwarded to match. The existing approval (review #472) is marked stale against the new head, so this is ready for re-approval/merge into dev whenever convenient.
vivy merged commit 2973265f51 into dev 2026-11-15 19:19:30 +00:00
vivy deleted branch fix/GRI-2109-playlist-delete-device-conflict 2026-11-15 19:19:31 +00:00
Sign in to join this conversation.
No reviewers
No milestone
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!246
No description provided.