Skip to content

Conversation

@heathdutton
Copy link

Fixes #6616

manage.py delete-user fails with an IntegrityError when deleting a user that has SeenMessage records. This happens because it calls db.session.delete() directly instead of using the Journalist.delete() method, which properly handles related records.

This change updates manage.py to use Journalist.delete(), matching the behavior of the Admin Interface.

Test plan

  1. Create a user via manage.py add-journalist
  2. Log in as that user via SecureDrop Client and read some messages (creating SeenMessage records)
  3. Run manage.py delete-user and enter the username
  4. Verify the user is deleted successfully without errors

Checklist

This change accounts for:

  • any required additional documentation
  • any necessary AppArmor changes (added or removed application files)
  • any impact on new SecureDrop installs and upgrades
  • our dependency update policy

@heathdutton heathdutton requested a review from a team as a code owner January 1, 2026 04:26
@zenmonkeykstop zenmonkeykstop moved this to Next sprint candidates in SecureDrop Jan 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Next sprint candidates

Development

Successfully merging this pull request may close these issues.

manage.py delete-user fails on a user with SeenMessage records

1 participant