Error during account deletion

Hello
I am getting an error while im trying to delete an account in self-hosted Open Edx. The user account I’m trying to delete is a superuser.
I have deployed using tutor and am using the latest version.
I have attached the error traceback below.

lms_1                        | 2022-04-25 12:41:23,409 ERROR 7 [openedx.core.djangoapps.user_api.accounts.views] [user 8] [ip 124.123.80.200] views.py:573 - 500 error deactivating account Default state does not exist! Populate retirement states to retire users.
lms_1                        | Traceback (most recent call last):
lms_1                        |   File "/openedx/edx-platform/./openedx/core/djangoapps/user_api/models.py", line 342, in create_retirement
lms_1                        |     pending = RetirementState.objects.all().order_by('state_execution_order')[0]
lms_1                        |   File "/openedx/venv/lib/python3.8/site-packages/django/db/models/query.py", line 318, in __getitem__
lms_1                        |     return qs._result_cache[0]
lms_1                        | IndexError: list index out of range
lms_1                        | 
lms_1                        | During handling of the above exception, another exception occurred:
lms_1                        | 
lms_1                        | Traceback (most recent call last):
lms_1                        |   File "/openedx/edx-platform/./openedx/core/djangoapps/user_api/accounts/views.py", line 539, in post
lms_1                        |     create_retirement_request_and_deactivate_account(request.user)
lms_1                        |   File "/openedx/edx-platform/./openedx/core/djangoapps/user_api/accounts/utils.py", line 201, in create_retirement_request_and_deactivate_account
lms_1                        |     UserRetirementStatus.create_retirement(user)
lms_1                        |   File "/openedx/edx-platform/./openedx/core/djangoapps/user_api/models.py", line 344, in create_retirement
lms_1                        |     raise RetirementStateError('Default state does not exist! Populate retirement states to retire users.')  # lint-amnesty, pylint: disable=raise-missing-from
lms_1                        | openedx.core.djangoapps.user_api.models.RetirementStateError: Default state does not exist! Populate retirement states to retire users.
lms_1                        | 2022-04-25 12:41:23,459 ERROR 7 [django.request] [user None] [ip None] log.py:224 - Internal Server Error: /api/user/v1/accounts/deactivate_logout/
caddy_1                      |

I also encountered this problem before, but I never fully implemented a solution.

I believe the key to the solution lies in this line.

You can take a look at this guide to populate this RETIREMENT_STATES dictionary.

https://edx.readthedocs.io/projects/edx-installing-configuring-and-running/en/latest/configuration/user_retire/service_setup.html

3 Likes

Thanks for sharing the specific doc link @uetuluk and pointing out the exact cause of the issue.

@uetuluk It’s not always easy to delete users, caused by many dependencies in the system. A quick and immediate help can be found into the Django panel.

Just disable the user: as active, as staff and as superusers member. The user can not have access any more.

1 Like

Got it, will do the same.
Thank you @abstract-technology.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.