Skip to content

Conversation

@jl141
Copy link

@jl141 jl141 commented Nov 30, 2025

SUMMARY

Fixes: #13345
When trying to delete a user, the error message "Associated data exists, please delete them first" appears. Even with all the charts and dashboards created by the user being deleted, the user being set as inactive, and their role setting deleted, it is not possible to delete the user.

Our changes involve:

  • Frontend UI changes and new backend API endpoints for asset reassignment (dashboards, charts, saved queries)
  • FK constraint rule modifications for hard deletion
  • New ab_user columns to support soft deletion

Regarding a user's action logs after they are deleted:

  • Hard deletion will result in the user's PII to disappear from the logs
  • Soft deletion will result in the user's username to stay intact in the logs

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Deletion UI before:
image
Deletion UI after:
image

TESTING INSTRUCTIONS

  1. Login as an admin
  2. Create a new user
  3. Login as the new user and create assets such as dashboards/charts/saved queries
  4. Login as admin and attempt to delete the user from the "List Users" page
  5. You will be prompted to reassign the user's assets, and choose whether or not to perform a soft delete (this option allows for future retrieval of this user's account from the database if needed)

ADDITIONAL INFORMATION

  • Has associated issue: cannot delete user "Associated data exists, please delete them first" #13345
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
      • Migration adds a nullable column - near-instant on all databases
      • Migration adds a boolean column (with default value) to the ab_user table - near-instant on all databases
      • Zero downtime - existing queries continue to work
  • Introduces new feature or API
  • Removes existing feature or API

@github-actions github-actions bot added risk:db-migration PRs that require a DB migration api Related to the REST API labels Nov 30, 2025
@jl141 jl141 changed the title Upgrade user deletion to allow for asset reassignment and the option for a soft/hard delete feat(users): user deletion to allow for asset reassignment and the option for a soft/hard delete Nov 30, 2025
@jl141 jl141 marked this pull request as ready for review November 30, 2025 20:55
@dosubot dosubot bot added change:backend Requires changing the backend change:frontend Requires changing the frontend global:users Related to users and roles risk:breaking-change Issues or PRs that will introduce breaking changes labels Nov 30, 2025
@rusackas
Copy link
Member

rusackas commented Dec 1, 2025

Thanks! @michael-s-molina was just discussing this recently.

@codecov
Copy link

codecov bot commented Dec 1, 2025

Codecov Report

❌ Patch coverage is 43.44262% with 69 lines in your changes missing coverage. Please review.
✅ Project coverage is 48.03%. Comparing base (341ae99) to head (41ad93b).
⚠️ Report is 64 commits behind head on master.

Files with missing lines Patch % Lines
superset/security/api.py 35.89% 50 Missing ⚠️
superset/migrations/shared/constraints.py 7.69% 12 Missing ⚠️
superset/queries/saved_queries/filters.py 25.00% 3 Missing ⚠️
superset/security/filters.py 75.00% 2 Missing ⚠️
superset/views/filters.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #36342       +/-   ##
===========================================
+ Coverage        0   48.03%   +48.03%     
===========================================
  Files           0      638      +638     
  Lines           0    46933    +46933     
  Branches        0     5096     +5096     
===========================================
+ Hits            0    22544    +22544     
- Misses          0    23738    +23738     
- Partials        0      651      +651     
Flag Coverage Δ
hive 43.74% <43.44%> (?)
presto 47.33% <43.44%> (?)
python 48.03% <43.44%> (?)
unit 100.00% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@michael-s-molina
Copy link
Member

Thank you for the PR, @jl141! I believe this feature would benefit from a SIP that aligns with and complements SIP-27: Proposal for Paranoid Deletes. Implementing soft deletion will impact several areas in Superset where users are referenced, such as datasets, charts, dashboards, and saved queries. Additionally, there’s an important distinction between items that can be reassigned and those that cannot—like log entries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Related to the REST API change:backend Requires changing the backend change:frontend Requires changing the frontend global:users Related to users and roles risk:breaking-change Issues or PRs that will introduce breaking changes risk:db-migration PRs that require a DB migration size/XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cannot delete user "Associated data exists, please delete them first"

5 participants