Skip to content

Cannot delete a team if it's part of notification rule #5222

@ryhoo2

Description

@ryhoo2

Current Behavior

When trying to delete a team that has been referenced in some notification rule (as recipient) there is Server Error 500 and the following server log:

2025-08-21 14:29:26,184 ERROR [Transaction] Operation commit failed on resource: org.datanucleus.store.rdbms.ConnectionFactoryImpl$EmulatedXAResource@213f4cb7, error code UNKNOWN and transaction [DataNucleus Transaction, ID=-1155218550-21406928, enlisted resources=[org.datanucleus.store.rdbms.ConnectionFactoryImpl$EmulatedXAResource@213f4cb7]] : ERROR: update or delete on table "TEAM" violates foreign key constraint "NOTIFICATIONRULE_TEAMS_FK2" on table "NOTIFICATIONRULE_TEAMS"
  Detail: Key (ID)=(33) is still referenced from table "NOTIFICATIONRULE_TEAMS". [principal=admin, requestUri=/v1/team, requestId=*****************, requestMethod=DELETE]
2025-08-21 14:29:26,184 ERROR [GlobalExceptionHandler] Uncaught internal server error [principal=admin, requestUri=/v1/team, requestId=***************, requestMethod=DELETE]
...
Caused by: org.postgresql.util.PSQLException: ERROR: update or delete on table "TEAM" violates foreign key constraint "NOTIFICATIONRULE_TEAMS_FK2" on table "NOTIFICATIONRULE_TEAMS"
  Detail: Key (ID)=(33) is still referenced from table "NOTIFICATIONRULE_TEAMS".
...

Steps to Reproduce

  1. Create a team called "team1"
  2. Create a notification alert/rule and assign "team1" as recipient to it.
  3. Delete "team1"

Server Error 500 is the response on the UI.

Expected Behavior

While deleting team it is first deleted from all notification rules (as recipient references) and then the team is deleted.

Dependency-Track Version

4.13.2

Dependency-Track Distribution

Container Image

Database Server

PostgreSQL

Database Server Version

No response

Browser

Google Chrome

Checklist

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions