feat: redact email PII in UnregisteredLearnerCohortAssignments before deletion#38651
Open
ttak-apphelix wants to merge 3 commits into
Open
feat: redact email PII in UnregisteredLearnerCohortAssignments before deletion#38651ttak-apphelix wants to merge 3 commits into
ttak-apphelix wants to merge 3 commits into
Conversation
ktyagiapphelix2u
approved these changes
May 19, 2026
Contributor
ktyagiapphelix2u
left a comment
There was a problem hiding this comment.
Look good to me
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
During user retirement,
UnregisteredLearnerCohortAssignmentsrecords were being deleted without first redacting the email field. This meant downstream systems (e.g. Snowflake) could see the raw email address in CDC/replication logs at the moment of deletion.This change redacts the email to its retired (hashed) value before deleting the record, consistent with how PII is handled for other tables during the retirement pipeline.
Private JIRA ticket
https://2u-internal.atlassian.net/browse/BOMS-565
Changes
openedx/core/djangoapps/user_api/accounts/views.pyUnregisteredLearnerCohortAssignments.delete_by_user_value()with an explicit ID-based redact-then-delete:original_emailUPDATEemail toretired_emailusingid__inDELETEthose same IDsopenedx/core/djangoapps/user_api/accounts/tests/test_retirement_views.pytest_cohort_assignment_email_redacted_before_deleteto verify at the SQL level (viaCaptureQueriesContext) that:id IN (...)filteringTesting
test_cohort_assignment_email_redacted_before_deleteinTestAccountRetirementPostcovers the fix end-to-end including the SQL query order and ID-based filtering assertions.test_retire_usercontinues to assert the record is deleted.