Error:bad server response displayed

Hi,

a mobile user is not able to log in, displaying Bad server response. the following is an error log displaying while trying to login. tail -f /home/cchq/www/echis/log/django.log

Traceback (most recent call last):
File “/home/cchq/www/echis/releases/2021-02-11_19.06/python_env-3.6/lib/python3.6/site-packages/django/core/handlers/exception.py”, line 34, in inner
response = get_response(request)
File “/home/cchq/www/echis/releases/2021-02-11_19.06/python_env-3.6/lib/python3.6/site-packages/django/core/handlers/base.py”, line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File “/home/cchq/www/echis/releases/2021-02-11_19.06/python_env-3.6/lib/python3.6/site-packages/django/core/handlers/base.py”, line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File “/home/cchq/www/echis/releases/2021-02-11_19.06/python_env-3.6/lib/python3.6/site-packages/sentry_sdk/integrations/django/views.py”, line 67, in sentry_wrapped_callback
return callback(request, *args, **kwargs)
File “/home/cchq/www/echis/releases/2021-02-11_19.06/corehq/apps/domain/decorators.py”, line 365, in _inner
return function_wrapper(fn)(request, *args, **kwargs)
File “/home/cchq/www/echis/releases/2021-02-11_19.06/corehq/apps/domain/decorators.py”, line 257, in safe_fn_with_domain
return _inner(request, domain, *args, **kwargs)
File “/home/cchq/www/echis/releases/2021-02-11_19.06/corehq/apps/domain/decorators.py”, line 537, in _inner
user = CouchUser.get_by_username(username)
File “/home/cchq/www/echis/releases/2021-02-11_19.06/python_env-3.6/lib/python3.6/site-packages/quickcache/quickcache.py”, line 42, in inner
return helper(*args, **kwargs)
File “/home/cchq/www/echis/releases/2021-02-11_19.06/python_env-3.6/lib/python3.6/site-packages/quickcache/quickcache_helper.py”, line 179, in call
return self.call(*args, **kwargs)
File “/home/cchq/www/echis/releases/2021-02-11_19.06/python_env-3.6/lib/python3.6/site-packages/quickcache/quickcache_helper.py”, line 74, in call
content = self.fn(*args, **kwargs)
File “/home/cchq/www/echis/releases/2021-02-11_19.06/corehq/apps/users/models.py”, line 1434, in get_by_username
username, ', '.join([row[‘id’] for row in result])
couchdbkit.exceptions.MultipleResultsFound: “gayi.1@fmoh-echis.commcarehq.org”: 18acd6b211ad4aa7b8a7ee8a2c0d241f, 4b3a833a3be8468bb8f5c24f9b01c5f5

Looking at the user list, i didn’t see any duplicates with gayi.1 as shown below

Hi Demisew

We haven’t been able to track down how these users get created but there is a management command to find them and delete them. It will delete the oldest duplicate user that does not have any form submissions.

python manage.py delete_duplicate_users fmoh-echis

Thanks Simon,

am able to delete most users using the above commands. but still some users remaining. the following error displayed while running the command.

Enter action [delete, print, quit]: delete
Checking gayi.2@fmoh-echis.commcarehq.org
Deleting 1 users for gayi.2@fmoh-echis.commcarehq.org
Deleting 2006fc3a39184da59905f814696f2d0e
Traceback (most recent call last):
File “manage.py”, line 194, in
main()
File “manage.py”, line 41, in main
execute_from_command_line(sys.argv)
File “/home/cchq/www/echis/releases/2021-02-11_19.06/python_env-3.6/lib/python3.6/site-packages/django/core/management/init.py”, line 381, in execute_from_comma
nd_line
utility.execute()
File “/home/cchq/www/echis/releases/2021-02-11_19.06/python_env-3.6/lib/python3.6/site-packages/django/core/management/init.py”, line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File “/home/cchq/www/echis/releases/2021-02-11_19.06/python_env-3.6/lib/python3.6/site-packages/django/core/management/base.py”, line 323, in run_from_argv
self.execute(*args, **cmd_options)
File “/home/cchq/www/echis/releases/2021-02-11_19.06/python_env-3.6/lib/python3.6/site-packages/django/core/management/base.py”, line 364, in execute
output = self.handle(*args, **options)
File “/home/cchq/www/echis/releases/2021-02-11_19.06/corehq/apps/cleanup/management/commands/delete_duplicate_users.py”, line 63, in handle
delete_duplicate_users(list(users_by_id.values()), users_to_delete)
File “/home/cchq/www/echis/releases/2021-02-11_19.06/corehq/apps/cleanup/management/commands/delete_duplicate_users.py”, line 111, in delete_duplicate_users
user_ids = live_user_ids_by_django_user[user.get_django_user().pk]
File “/home/cchq/www/echis/releases/2021-02-11_19.06/corehq/apps/users/models.py”, line 1247, in get_django_user
return queryset.get(username__iexact=self.username)
File “/home/cchq/www/echis/releases/2021-02-11_19.06/python_env-3.6/lib/python3.6/site-packages/django/db/models/manager.py”, line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File “/home/cchq/www/echis/releases/2021-02-11_19.06/python_env-3.6/lib/python3.6/site-packages/django/db/models/query.py”, line 408, in get
self.model._meta.object_name
django.contrib.auth.models.DoesNotExist: User matching query does not exist.

Hi Demisew

That error happens right at the end of the script and since you only had 1 duplicate I don’t think there’s anything left to do.