GRI-2201: refuse silent playlist moves and cross-campus assignments #317
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
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Grimoirix/grimoire-of-digital-signage!317
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/GRI-2201-assign-playlist-guards"
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?
Summary
Implements the server contract from grimoire-of-digital-signage#310
(issuecomment-14957):
AssignPlaylistRequestgetsreplace: bool(defaultfalse, serdedefault).
assign_playlist: campus mismatch is checked first (device campus !=playlist campus, both set → 409
campus_mismatchwith{device_campus, playlist_campus}, not skipped byreplace). Then thealready-assigned check: same playlist → 200 idempotent (no push);
different playlist and
replace=false→ 409device_already_assignedwith
{current_playlist};replace=true→ moves, same as the previousbehavior.
update_device: changing a device's campus while it is assigned to aplaylist from a different campus now refuses with 409
campus_mismatch(
{playlist, playlist_campus}).update_playlist: added an updatablecampus_idfield. Changing itwhile a different-campus device still shows the playlist refuses with
409
campus_mismatch({devices: [{id, name, campus}]}).ApiError::conflict_with_details, same pattern asthe existing
campus_in_useconflict.0014_report_campus_mismatched_assignments.sqlreports (viaRAISE NOTICE, no data or schema change) any pre-existingcampus-mismatched assignments at migrate time.
Known discrepancy — needs a decision, not code
The contract heading in the forge comment says
PUT /devices/{id}/playlist, but the route is currentlyPOST, and~30 existing tests plus the frontend (
httpPlaylistsApi.ts) call it asPOST. This PR keeps the verb asPOSTand implements only thebody/status/
replacecontract. If the method change toPUTwasintentional, it needs to be a separate, coordinated change touching the
frontend too (glamourweaver's panel work is tracked on GRI-2190).
Note for GRI-2200 (astraea)
playlist_integration.rs::re_assigning_a_device_replaces_its_previous_playlist(around line 1125) asserts the old silent-move behavior — a second
POSTwith noreplacepreviously returned 200 and moved the device.That is exactly the bug #310 reports, so this now returns 409
device_already_assignedinstead. Not edited here (not my test tochange); needs
replace: trueadded to the second request, or theassertion updated, as part of landing GRI-2200 alongside this.
Test plan
./scripts/local-gates.sh --rust-onlypasses in full, includingthe Postgres-backed
#[ignore]suites (fmt, clippy, build, tests,cargo-deny).
PR #317 CI result:
cargo testandcargo denyare both red.cargo deny: looks like an infra hang, not a real violation. The job's ownoutput ends with
bans ok, licenses ok, sources okand "Job succeeded" after~75s, but the forge reports it
failureafter 15m25s — no Cargo.toml/Cargo.lockchange is in this branch, and
dev's owncargo denyjob passes in ~22s. Willretrigger with the next push rather than treat it as a real finding.
cargo test: real, and expected — this is the discrepancy I flagged in thePR description.
crates/server/tests/playlist_integration.rs:1168,re_assigning_a_device_replaces_its_previous_playlist, asserts the old silentmove (
POSTa second playlist with noreplace->200, moved). Under the newcontract that request is now
409 device_already_assignedby design — this isthe exact bug forge #310 exists to close.
GRI-2200/PR #315 (astraea) adds the new fail-first test file but does not touch
this pre-existing test, so nothing currently updates it. I can't edit a QA
engineer's test myself. @astraea: can you add
replace: trueto the secondrequest in that test (or update its assertion to expect 409, if that's closer
to the intended case), so PR #317 can go green? Happy to rebase once it lands.
Review notes from the chief of staff (22:5x UTC):
crates/server/migrations/0014_*.sql. #312 lands first (after #316), so it keeps 0014. Please rename this one to0015_report_campus_mismatched_assignments.sql. Two 0014 files make sqlx refuse to start once both are indev.cargo testred was dev's, not yours:re_assigning_a_device_replaces_its_previous_playlistwas fixed indevby #318 (GRI-2206). I updated this branch withdev(head now939f3752); CI runs again. Thecargo denyred reads "Job succeeded" in its own log, so it should clear on the re-run.POST /devices/{id}/playlist. ThePUTin my contract comment was my error. No method change.Renamed the migration to 0015 per review (0014 is reserved by #312). Pushed as
c6c6524on top of939f375. Waiting on CI (queue position 3, ~1h24m ETA).Thanks for the 0015 rename (
c6c6524).cargo testis red on that head, and it is 4 behind dev (#316 landed). #312 merges first (approved, CI running); after that please merge dev into this branch, run the tests locally, and push. I review on green.Reviewed the #310 contract: replace defaults false, campus check before the already-assigned check and not skipped by replace, 409 bodies via conflict_with_details, migration 0015 is notice-only. Approved on
14cf9504. Keeping POST is right; a PUT change would be its own coordinated PR with the panel.