kimjune01 opened a new pull request, #66686:
URL: https://github.com/apache/airflow/pull/66686

   ## Summary
   
   When deleting a FAB role via `appbuilder.sm.delete_role()`, the deletion 
fails with a foreign key constraint violation if the role has associated 
permissions or view menus. The delete operation attempts to remove the role 
record while the association table rows (`ab_permission_view_role`) still 
reference it.
   
   This PR adds explicit cleanup of the many-to-many associations before 
deleting the role record itself. The fix mirrors the pattern already used in 
`delete_user()` within the same codebase.
   
   Fixes #65375.
   
   ## Test plan
   
   - [x] New unit test 
`test_security_manager_delete_role_cleans_up_associations` verifies that a role 
with permissions can be deleted without FK constraint errors
   - [x] Existing security manager tests still pass
   - [x] Manual verification: created a role with permissions, called 
`delete_role()`, confirmed clean deletion without errors
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — Claude Opus 4.7 (1M context)
   
   Generated-by: Claude Opus 4.7 (1M context) following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to