Skip to content

fix: Redact uid field and delete records for retired users from support_historicalusersocialauth#38658

Merged
robrap merged 39 commits into
openedx:masterfrom
Akanshu-2u:aaich/BOMS-577
Jun 4, 2026
Merged

fix: Redact uid field and delete records for retired users from support_historicalusersocialauth#38658
robrap merged 39 commits into
openedx:masterfrom
Akanshu-2u:aaich/BOMS-577

Conversation

@Akanshu-2u

@Akanshu-2u Akanshu-2u commented May 19, 2026

Copy link
Copy Markdown
Contributor

Description:

Ensures PII in django-simple-history snapshots of social auth records is redacted before deletion during user retirement.

Changes:

  • Add redact_and_delete_historical_social_auth utility that bulk-redacts uid and clears extra_data before bulk-deleting rows.
  • Invoke the utility from LMSAccountRetirementView.post() in the retirement workflow.
  • Gracefully skips on deployments where the support app is not installed.
  • Add and strengthen tests across test_utils.py, test_retire_user.py, and test_retirement_views.py using the shared assert_redact_before_delete helper.

Private JIRA Link:

BOMS-577

@Akanshu-2u Akanshu-2u requested a review from a team as a code owner May 19, 2026 15:03
@Akanshu-2u Akanshu-2u requested review from Copilot and removed request for a team May 19, 2026 15:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR strengthens user retirement by ensuring PII stored in django-simple-history snapshots of social auth records is redacted and removed during the retirement workflow.

Changes:

  • Call a new retirement utility to redact+delete HistoricalUserSocialAuth rows during user retirement.
  • Add redact_and_delete_historical_social_auth utility that updates uid/extra_data then deletes historical rows.
  • Add LMS tests covering UPDATE-before-DELETE behavior and deletion scope.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
openedx/core/djangoapps/user_api/accounts/views.py Invokes the new historical social auth redaction/deletion step during retirement.
openedx/core/djangoapps/user_api/accounts/utils.py Adds a utility to redact+delete historical social auth snapshots that can retain PII.
openedx/core/djangoapps/user_api/accounts/tests/test_utils.py Adds tests validating query ordering and deletion behavior for historical social auth redaction.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread openedx/core/djangoapps/user_api/accounts/utils.py Outdated
Comment thread openedx/core/djangoapps/user_api/accounts/tests/test_utils.py Outdated
@Akanshu-2u Akanshu-2u requested a review from Copilot May 19, 2026 16:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread openedx/core/djangoapps/user_api/accounts/utils.py Outdated
Comment thread openedx/core/djangoapps/user_api/accounts/tests/test_utils.py Outdated
Akanshu-2u and others added 2 commits May 19, 2026 22:19
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@Akanshu-2u Akanshu-2u requested a review from Copilot May 19, 2026 16:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread openedx/core/djangoapps/user_api/accounts/tests/test_utils.py Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@Akanshu-2u Akanshu-2u requested a review from Copilot May 19, 2026 17:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread openedx/core/djangoapps/user_api/accounts/utils.py Outdated
@Akanshu-2u Akanshu-2u requested a review from Copilot May 19, 2026 17:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment thread openedx/core/djangoapps/user_api/accounts/utils.py Outdated
Comment thread openedx/core/djangoapps/user_api/accounts/tests/test_utils.py Outdated
Comment thread openedx/core/djangoapps/user_api/accounts/tests/test_utils.py Outdated
@Akanshu-2u Akanshu-2u requested a review from Copilot May 19, 2026 18:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread openedx/core/djangoapps/user_api/accounts/utils.py Outdated
Comment thread openedx/core/djangoapps/user_api/accounts/tests/test_utils.py Outdated
@Akanshu-2u Akanshu-2u requested a review from Copilot May 19, 2026 18:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment thread openedx/core/djangoapps/user_api/accounts/tests/test_utils.py Outdated
Comment thread openedx/core/djangoapps/user_api/accounts/tests/test_utils.py Outdated
Comment thread openedx/core/djangoapps/user_api/accounts/utils.py Outdated
@Akanshu-2u Akanshu-2u requested a review from Copilot May 19, 2026 18:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread openedx/core/djangoapps/user_api/accounts/utils.py Outdated
@Akanshu-2u Akanshu-2u requested a review from Copilot May 20, 2026 09:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment thread openedx/core/djangoapps/user_api/accounts/tests/test_utils.py Outdated
Comment thread openedx/core/djangoapps/user_api/accounts/tests/test_utils.py Outdated
Comment thread openedx/core/djangoapps/user_api/accounts/tests/test_utils.py Outdated

@ktyagiapphelix2u ktyagiapphelix2u left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@robrap robrap left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Updates requested.

Comment thread openedx/core/djangoapps/user_api/accounts/tests/test_utils.py Outdated
Comment thread openedx/core/djangoapps/user_api/accounts/tests/test_utils.py Outdated
Comment thread openedx/core/djangoapps/user_api/accounts/tests/test_utils.py Outdated
Comment thread openedx/core/djangoapps/user_api/accounts/views.py
Comment thread openedx/core/djangoapps/user_api/accounts/tests/test_utils.py
Comment thread openedx/core/djangoapps/user_api/accounts/tests/test_utils.py Outdated

@robrap robrap left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. It's close. Thank you.

Comment thread openedx/core/djangoapps/user_api/accounts/tests/test_utils.py Outdated
Comment thread openedx/core/djangoapps/user_api/accounts/tests/test_utils.py
Comment thread openedx/core/djangoapps/user_api/accounts/tests/test_utils.py Outdated
Comment thread openedx/core/djangoapps/user_api/accounts/tests/test_utils.py Outdated
Comment thread openedx/core/djangoapps/user_api/management/tests/test_retire_user.py Outdated

@robrap robrap left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, but let me know if you update before we meet.

Comment thread openedx/core/djangoapps/user_api/accounts/tests/test_utils.py Outdated
Comment thread openedx/core/djangoapps/user_api/management/tests/test_retire_user.py Outdated
Comment thread openedx/core/djangoapps/user_api/management/tests/test_retire_user.py Outdated
@robrap robrap enabled auto-merge (squash) June 4, 2026 19:21
@robrap robrap merged commit 0ad7c6c into openedx:master Jun 4, 2026
40 of 41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants