GRI-2109: return 409 on playlist delete with devices assigned, offer unassign #246
No reviewers
Labels
No labels
Area/Backend
Area/Database
Area/Docs
Area/Frontend
Area/Infra
Area/Security
Area/Tests
Area/Tooling
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Lang/Python
Lang/Rust
Lang/Shell
Lang/SQL
Lang/TypeScript
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Routing
Auto
Routing
Hold
Routing
Human
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Grimoirix/grimoire-of-digital-signage!246
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/GRI-2109-playlist-delete-device-conflict"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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:409 device_assignednaming the blocking devices (id,name)when any device is assigned the playlist;
?unassign_devices=true, unassigns those devices (pushingPlaylistCleared, or marking pending-clear if offline — same asDELETE /devices/{device_id}/playlist) and deletes the playlist, in onetransaction.
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.rscovering a playlist withassigned devices, both online and offline, plus the plain-conflict and
success paths.
Test plan
./scripts/local-gates.sh --rust-only— every gate passed locally.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.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_idjoined to devices would close that. Fine as a follow-up comment on the issue.CI is green on
ef87086(CTO mergeddevinto this branch again after approving5f17186— 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.