fix: handle missing forum account gracefully during user retirement#317
Open
mariajgrimaldi wants to merge 1 commit into
Open
fix: handle missing forum account gracefully during user retirement#317mariajgrimaldi wants to merge 1 commit into
mariajgrimaldi wants to merge 1 commit into
Conversation
c372880 to
0df4e9e
Compare
Two cases now handled in the forum-v2 path of User.retire(): - ForumV2RequestError: user has no forum account (never posted), no-op. - IntegrityError: blank email already used by a previously retired user; the forum package sets email="" which violates the unique constraint when another retired user already has that value. Log and continue. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
0df4e9e to
8f17875
Compare
Author
|
Hi there, @eduNEXT/heimdall! Can I get a quick review here? Thanks! |
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
Two cases in the forum-v2 retirement path were causing a 500 and leaving the retirement pipeline stuck.
Case 1: user with no forum account. Users who have never posted have no forum record.
forum_api.retire_user()raisesForumV2RequestError("user not found"), which was not being caught. The retirement endpoint returned 500, triggering the script's backoff-and-retry loop.Case 2: duplicate email constraint. The forum MySQL backend sets
email=""onauth_userduring retirement. On deployments with a unique constraint onauth_user.email, retiring a second user fails withIntegrityError: Duplicate entry '' for key 'auth_user.email'. The LMS retirement pipeline generates a unique hashed email per user viaget_retired_email_by_email; the forum package doesn't. Not sure why this isn't tracked as an upstream issue already.Both cases are now caught in
User.retire()inside the forum-v2 path and treated as non-fatal. The retirement step completes and the pipeline continues.Supporting information
Root cause trace:
POST /api/discussion/v1/accounts/retire_forum/(retirement script)RetireUserView.post()indiscussion/rest_api/views.pycomment_client.User.retire()forum_api.retire_user()raisesForumV2RequestError(no forum account) orIntegrityError(duplicate blank email)Testing instructions
POST /api/discussion/v1/accounts/retire_forum/directly with the service worker credentials.RETIRING_FORUMSstep.auth_user.email.Deadline
None.
Other information
No migrations. No API contract changes. The endpoint's behavior for these two cases changes from 500 to 204.