GRI-2180: match restrict_violation (23001) alongside foreign_key_violation (23503) #309
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!309
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/GRI-2180-pg18-restrict-violation-code"
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
Forge issue #223 was reopened:
delete_playlist(anddelete_media,delete_campus) each kept their own copy ofis_foreign_key_violation,matching only SQLSTATE
23503. On the campus test server, which runsPostgreSQL 18 from the Ubuntu 26.04 package, the reopening comment
suspected the RESTRICT violation surfaces as
23001instead, so the 409path was never taken and the raw database error passed through
delete_playlist's handler as a 500.is_foreign_key_violationindb.rs, matching both23503and23001, and removed the three private copies incampus.rs,media/handlers.rsandplaylists/handlers.rsin favourof it.
db.rspinning the predicate against both codes(and against an unrelated code and a non-
Databaseerror), using ahand-rolled
DatabaseErrorimpl sincesqlx's real one is notpublicly constructible outside the driver.
Caveat worth flagging to whoever verifies this on the campus server:
I could not reproduce SQLSTATE
23001locally. This build host's ownPostgreSQL is in fact 18.6, and a direct
ON DELETE RESTRICTviolationagainst it — both through a minimal reproduction and through the full
playlist_integration/campus_integration/media_integrationsuitesrun against it live — consistently reports
23503, the same code andthe same message shape as PostgreSQL 16. So the real SQLSTATE the
campus server returns is still unconfirmed; this change is a safe,
zero-cost broadening that covers the suspected code either way, but if
the campus server is still returning 500 after this lands, the next
step is a direct
\errverbosecapture there rather than another guessat the code.
I did not touch
.github/workflows/ci.yml(the issue's "run the suiteagainst postgres:18 too" suggestion) — CI configuration is outside what
I'm permitted to change; flagged to the chief of staff separately.
Test plan
cargo test -p server --lib db::— new unit tests, both SQLSTATEscargo clippy --workspace --all-targets --locked -- -D warningscargo fmt --all --checkcargo test --workspace --lockedagainst a live PostgreSQL 18.6(
SIGNAGE_TEST_DATABASE_URL=postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable) — all green, includingdeleting_a_playlist_assigned_to_a_device_is_refused,deleting_a_campus_still_referenced_by_media_is_refused, and themedia-in-use tests
access to it