Unable to Delete User

Hello,

I am running Tutor v14, and get the following error when trying to delete a user.

I am trying to delete a user (get a 500 error from the web interface), and from the CLI I get the same thing

app@5420e5d8b2a3:~/edx-platform$ python manage.py lms manage_user --remove tmisilotest tmisilo@gmail.com
2022-11-14 23:28:24,257 WARNING 46 [py.warnings] [user None] [ip None] warnings.py:109 - /openedx/venv/lib/python3.8/site-packages/boto/plugin.py:40: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp

2022-11-14 23:28:24,320 WARNING 46 [py.warnings] [user None] [ip None] warnings.py:109 - /openedx/venv/lib/python3.8/site-packages/botocore/vendored/requests/packages/urllib3/_collections.py:1: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working
  from collections import Mapping, MutableMapping

2022-11-14 23:28:26,301 WARNING 46 [py.warnings] [user None] [ip None] warnings.py:109 - /openedx/edx-platform/openedx/core/types/admin.py:49: DeprecationWarning: Django 3.2+ available: the _admin_display method and the AdminMethodclass should be removed from openedx.core.types
  warnings.warn(

2022-11-14 23:28:26,985 WARNING 46 [py.warnings] [user None] [ip None] warnings.py:109 - /openedx/venv/lib/python3.8/site-packages/swiftclient/client.py:84: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
  if StrictVersion(requests.__version__) < StrictVersion('2.0.0') \

System check identified some issues:

WARNINGS:
?: (2_0.W001) Your URL pattern 'edx_name_affirmation/v1/verified_name/(?P<verified_name_id>\d+)$' [name='verified_name_by_id'] has a route that contains '(?P<', begins with a '^', or ends with a '$'. This was likely an oversight when migrating to django.urls.path().
consent.DataSharingConsent.granted: (fields.W903) NullBooleanField is deprecated. Support for it (except in historical migrations) will be removed in Django 4.0.
	HINT: Use BooleanField(null=True) instead.
consent.HistoricalDataSharingConsent.granted: (fields.W903) NullBooleanField is deprecated. Support for it (except in historical migrations) will be removed in Django 4.0.
	HINT: Use BooleanField(null=True) instead.
Removing user: "tmisilotest"
Traceback (most recent call last):
  File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 73, in execute
    return self.cursor.execute(query, args)
  File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/cursors.py", line 206, in execute
    res = self._query(query)
  File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/cursors.py", line 319, in _query
    db.query(q)
  File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/connections.py", line 254, in query
    _mysql.connection.query(self, query)
MySQLdb._exceptions.OperationalError: (1054, "Unknown column 'third_party_auth_ltiproviderconfig.visible' in 'field list'")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 106, in <module>
    execute_from_command_line([sys.argv[0]] + django_args)
  File "/openedx/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/openedx/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/openedx/venv/lib/python3.8/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/openedx/venv/lib/python3.8/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/opt/pyenv/versions/3.8.12/lib/python3.8/contextlib.py", line 75, in inner
    return func(*args, **kwds)
  File "/openedx/venv/lib/python3.8/site-packages/edx_django_utils/user/management/commands/manage_user.py", line 97, in handle
    self._handle_remove(username, email)
  File "/openedx/venv/lib/python3.8/site-packages/edx_django_utils/user/management/commands/manage_user.py", line 88, in _handle_remove
    user.delete()
  File "/openedx/venv/lib/python3.8/site-packages/django/db/models/base.py", line 966, in delete
    collector.collect([self], keep_parents=keep_parents)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/models/deletion.py", line 295, in collect
    if sub_objs:
  File "/openedx/venv/lib/python3.8/site-packages/django/db/models/query.py", line 284, in __bool__
    self._fetch_all()
  File "/openedx/venv/lib/python3.8/site-packages/django/db/models/query.py", line 1324, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "/openedx/venv/lib/python3.8/site-packages/django/db/models/query.py", line 51, in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1175, in execute_sql
    cursor.execute(sql, params)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/openedx/venv/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 73, in execute
    return self.cursor.execute(query, args)
  File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/cursors.py", line 206, in execute
    res = self._query(query)
  File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/cursors.py", line 319, in _query
    db.query(q)
  File "/openedx/venv/lib/python3.8/site-packages/MySQLdb/connections.py", line 254, in query
    _mysql.connection.query(self, query)
django.db.utils.OperationalError: (1054, "Unknown column 'third_party_auth_ltiproviderconfig.visible' in 'field list'")

Any ideas on how I can delete the user?

Thanks!

Greetings,

You might try the suggestions in this post:

As for your specific error:

I recall having this problem (or similar) on our site when trying to delete users who created accounts using the OAuth. Removing linked references to the user might help. Also, searching for and then deleting the third-party auth tokens for the specific user might remove the reference to the unknown column.

Hi Tony,

I will try that, but seems a little overkill for trying to delete a user I just created 30 seconds ago type of scenario, or one that has been there a long time. It seems like a bug in the system :frowning:

Tom

It’s very possible that your problem could be a bug. In other cases, it seems the delete option does not know about (or consider) user references in other MySQL tables. I know that forum references are left in the MongoDB tables, which then require manual deletion/manipulation if that user is to be used again. Otherwise, the forums crash.

I agree that problems like these leave a negative user experience and distract from the intended outcomes when we want to focus on using the platform to facilitate learning. Actually, there is a lot that should be improved in the platform for it to be used in formal education effectively. We’ve been trying for two years, but I also realize that the platform was developed for non-formal learning methodologies and contexts.