October 25, 2021

Fixing Unable to Delete Account Open edX via User Profile

Activities, Android Developer, Ansible, Apache2, Atlassian, Ayo Belajar Linux, Bestpath Network, BLC Telkom Klaten, BSD, Caddy Server, Case Study, Cisco, Cisco Indonesia, Cloud Computing, Cockpit, Custom Weapons, Docker, E-Learning, Engenius, Error, FreeBSD, FreeBSD Indonesia, Komunitas Pengguna Linux Indonesia, KPLI Bulukumba, KPLI Klaten, Let's Encrypt, Linux, MacOS, Microsoft Azure, Microsoft SQL Server, MikroTik, MikroTik Indonesia, MySQL, Nginx, Open edX, OpenSID, Others, PHP, phpMyAdmin, PostgreSQL, Proxmox, Python, Redash, Sendy, SSH, Stories, Subnetting, TP-Link, Ubiquiti, Unix, Virtualization, Windows, X-Mosque, Faizar Septiawan, Icar, siBunglonGanteng, Orang Ganteng, siBunglonLabs

When I test to delete my account from the user profile page, I get the following message after entering the password.

Activities, Android Developer, Ansible, Apache2, Atlassian, Ayo Belajar Linux, Bestpath Network, BLC Telkom Klaten, BSD, Caddy Server, Case Study, Cisco, Cisco Indonesia, Cloud Computing, Cockpit, Custom Weapons, Docker, E-Learning, Engenius, Error, FreeBSD, FreeBSD Indonesia, Komunitas Pengguna Linux Indonesia, KPLI Bulukumba, KPLI Klaten, Let's Encrypt, Linux, MacOS, Microsoft Azure, Microsoft SQL Server, MikroTik, MikroTik Indonesia, MySQL, Nginx, Open edX, OpenSID, Others, PHP, phpMyAdmin, PostgreSQL, Proxmox, Python, Redash, Sendy, SSH, Stories, Subnetting, TP-Link, Ubiquiti, Unix, Virtualization, Windows, X-Mosque, Faizar Septiawan, Icar, siBunglonGanteng, Orang Ganteng, siBunglonLabs

When check the file /edx/var/log/lms/edx.log i find this.

openedx.core.djangoapps.user_authn.exceptions.AuthFailedError
Oct 25 13:08:55 ubuntu [service_variant=lms][openedx.core.djangoapps.user_api.accounts.views][env:sandbox] ERROR [ubuntu  10792] [user 14] [views.py:472] - 500 error deactivating account Default state does not exist! Populate retirement states to retire users.
Traceback (most recent call last):
  File "/edx/app/edxapp/edx-platform/openedx/core/djangoapps/user_api/models.py", line 320, in create_retirement
    pending = RetirementState.objects.all().order_by('state_execution_order')[0]
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.5/site-packages/django/db/models/query.py", line 309, in __getitem__
    return qs._result_cache[0]
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/edx/app/edxapp/edx-platform/openedx/core/djangoapps/user_api/accounts/views.py", line 423, in post
    UserRetirementStatus.create_retirement(request.user)
  File "/edx/app/edxapp/edx-platform/openedx/core/djangoapps/user_api/models.py", line 322, in create_retirement
    raise RetirementStateError('Default state does not exist! Populate retirement states to retire users.')
openedx.core.djangoapps.user_api.models.RetirementStateError: Default state does not exist! Populate retirement states to retire users.
Oct 25 13:08:55 ubuntu [service_variant=lms][django.request][env:sandbox] ERROR [ubuntu  10792] [user None] [log.py:228] - Internal Server Error: /api/user/v1/accounts/deactivate_logout/

How to fix it?

populate the states table with the following command.

sudo -H -u edxapp bash
source /edx/app/edxapp/edxapp_env
cd /edx/app/edxapp/edx-platform
./manage.py lms --settings=production populate_retirement_states

Tested

  • release juniper.master