Site.objects.get() yields RecursionError with https but not with http

I am having some weird problem which started happening after the migration to Django 3.2. Using 3.2.1 now. The way to reproduce is:

  1. Build docker image & spin a container
  2. Apply all migrations
  3. Try accessing the app via http - works fine, loads login page
  4. Try accessing the app via https - fails with RecursionError exception.

The trigger seems to be from line 21 in my custom middleware:

(which tries to figure out if the DB is accessible and if not fallback to a web based ./manage.py migrate)

Additional info:

The test script which fails is test_http.sh. Before that I’ve got another one executed which performs similar assertions and it works just fine (test_docker.sh).

Full steps to reproduce:

git clone GitHub - kiwitcms/Kiwi: the leading open source test management system
cd Kiwi/
make docker-image
docker-compose run -e KIWI_DONT_ENFORCE_HTTPS=true --name kiwi_web web /httpd-foreground
docker exec -it kiwi_web /Kiwi/manage.py migrate

IP_ADDRESS=docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' kiwi_web
curl -L -o- http://$IP_ADDRESS:8080/ | grep ‘Welcome to Kiwi TCMS’

^^^ no errors till now.

curl -k -L -o- https://$IP_ADDRESS:8443/ | grep ‘Welcome to Kiwi TCMS’

^^^ FAILS.

Full error log from the container:

[Wed May 05 10:30:03.400178 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854] mod_wsgi (pid=11): Exception occurred processing WSGI script '/venv/lib64/python3.6/site-packages/tcms/wsgi.py'.
[Wed May 05 10:30:03.403316 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854] Traceback (most recent call last):
[Wed May 05 10:30:03.403514 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/django/core/handlers/exception.py", line 47, in inner
[Wed May 05 10:30:03.403522 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     response = get_response(request)
[Wed May 05 10:30:03.403529 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/django/utils/deprecation.py", line 116, in __call__
[Wed May 05 10:30:03.403533 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     response = self.process_request(request)
[Wed May 05 10:30:03.403539 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/tcms/core/middleware.py", line 21, in process_request
[Wed May 05 10:30:03.403546 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     Site.objects.get(pk=settings.SITE_ID)
[Wed May 05 10:30:03.403555 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/django/db/models/manager.py", line 85, in manager_method
[Wed May 05 10:30:03.403561 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     return getattr(self.get_queryset(), name)(*args, **kwargs)
[Wed May 05 10:30:03.403570 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/django/db/models/query.py", line 424, in get
[Wed May 05 10:30:03.403576 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     clone = self._chain() if self.query.combinator else self.filter(*args, **kwargs)
[Wed May 05 10:30:03.403584 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/django/db/models/query.py", line 941, in filter
[Wed May 05 10:30:03.403589 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     return self._filter_or_exclude(False, args, kwargs)
[Wed May 05 10:30:03.403597 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/django/db/models/query.py", line 961, in _filter_or_exclude
[Wed May 05 10:30:03.403605 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     clone._filter_or_exclude_inplace(negate, args, kwargs)
[Wed May 05 10:30:03.403613 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/django/db/models/query.py", line 968, in _filter_or_exclude_inplace
[Wed May 05 10:30:03.403619 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     self._query.add_q(Q(*args, **kwargs))
[Wed May 05 10:30:03.403629 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/django/db/models/sql/query.py", line 1391, in add_q
[Wed May 05 10:30:03.403636 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     clause, _ = self._add_q(q_object, self.used_aliases)
[Wed May 05 10:30:03.403643 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/django/db/models/sql/query.py", line 1415, in _add_q
[Wed May 05 10:30:03.403648 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     joinpromoter.add_votes(needed_inner)
[Wed May 05 10:30:03.403657 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/django/db/models/sql/query.py", line 2434, in add_votes
[Wed May 05 10:30:03.403668 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     self.votes.update(votes)
[Wed May 05 10:30:03.403676 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/collections/__init__.py", line 614, in update
[Wed May 05 10:30:03.403682 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     if isinstance(iterable, Mapping):
[Wed May 05 10:30:03.403690 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/abc.py", line 193, in __instancecheck__
[Wed May 05 10:30:03.403695 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     return cls.__subclasscheck__(subclass)
[Wed May 05 10:30:03.403705 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/abc.py", line 228, in __subclasscheck__
[Wed May 05 10:30:03.403710 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     if issubclass(subclass, scls):
[Wed May 05 10:30:03.403719 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/abc.py", line 228, in __subclasscheck__
[Wed May 05 10:30:03.403724 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     if issubclass(subclass, scls):
[Wed May 05 10:30:03.403732 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/usr/lib64/python3.6/typing.py", line 1154, in __subclasscheck__
[Wed May 05 10:30:03.403738 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     return super().__subclasscheck__(cls)
[Wed May 05 10:30:03.403746 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/abc.py", line 228, in __subclasscheck__
[Wed May 05 10:30:03.403752 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     if issubclass(subclass, scls):
[Wed May 05 10:30:03.403761 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/typing_extensions.py", line 800, in __subclasscheck__
[Wed May 05 10:30:03.403766 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     if issubclass(subclass, scls):
[Wed May 05 10:30:03.403775 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/typing_extensions.py", line 800, in __subclasscheck__
[Wed May 05 10:30:03.403780 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     if issubclass(subclass, scls):
[Wed May 05 10:30:03.403785 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/typing_extensions.py", line 800, in __subclasscheck__
[Wed May 05 10:30:03.403790 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     if issubclass(subclass, scls):
[Wed May 05 10:30:03.403797 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   [Previous line repeated 236 more times]
[Wed May 05 10:30:03.403803 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/typing_extensions.py", line 784, in __subclasscheck__
[Wed May 05 10:30:03.403809 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     if sys.version_info[:3] >= (3, 5, 3) or sys.version_info[:3] < (3, 5, 0):
[Wed May 05 10:30:03.403826 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854] RecursionError: maximum recursion depth exceeded in comparison
[Wed May 05 10:30:03.403836 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854] 
[Wed May 05 10:30:03.403841 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854] During handling of the above exception, another exception occurred:
[Wed May 05 10:30:03.403846 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854] 
[Wed May 05 10:30:03.403853 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854] Traceback (most recent call last):
[Wed May 05 10:30:03.404071 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/tcms/wsgi.py", line 43, in application
[Wed May 05 10:30:03.404077 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     return _APPLICATION(environ, start_response)
[Wed May 05 10:30:03.404083 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/django/core/handlers/wsgi.py", line 133, in __call__
[Wed May 05 10:30:03.404087 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     response = self.get_response(request)
[Wed May 05 10:30:03.404092 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/django/core/handlers/base.py", line 130, in get_response
[Wed May 05 10:30:03.404095 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     response = self._middleware_chain(request)
[Wed May 05 10:30:03.404104 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/django/core/handlers/exception.py", line 49, in inner
[Wed May 05 10:30:03.404110 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     response = response_for_exception(request, exc)
[Wed May 05 10:30:03.404119 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/django/core/handlers/exception.py", line 114, in response_for_exception
[Wed May 05 10:30:03.404156 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
[Wed May 05 10:30:03.404171 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/django/core/handlers/exception.py", line 152, in handle_uncaught_exception
[Wed May 05 10:30:03.404179 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     callback = resolver.resolve_error_handler(500)
[Wed May 05 10:30:03.404193 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/django/urls/resolvers.py", line 611, in resolve_error_handler
[Wed May 05 10:30:03.404199 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     callback = getattr(self.urlconf_module, 'handler%s' % view_type, None)
[Wed May 05 10:30:03.404206 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/django/utils/functional.py", line 48, in __get__
[Wed May 05 10:30:03.404212 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     res = instance.__dict__[self.name] = self.func(instance)
[Wed May 05 10:30:03.404221 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/django/urls/resolvers.py", line 591, in urlconf_module
[Wed May 05 10:30:03.404226 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     return import_module(self.urlconf_name)
[Wed May 05 10:30:03.404234 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/importlib/__init__.py", line 126, in import_module
[Wed May 05 10:30:03.404241 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     return _bootstrap._gcd_import(name[level:], package, level)
[Wed May 05 10:30:03.404250 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "<frozen importlib._bootstrap>", line 994, in _gcd_import
[Wed May 05 10:30:03.404259 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "<frozen importlib._bootstrap>", line 971, in _find_and_load
[Wed May 05 10:30:03.404268 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
[Wed May 05 10:30:03.404278 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
[Wed May 05 10:30:03.404287 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "<frozen importlib._bootstrap_external>", line 678, in exec_module
[Wed May 05 10:30:03.404295 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
[Wed May 05 10:30:03.404304 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/tcms/urls.py", line 20, in <module>
[Wed May 05 10:30:03.404311 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     from tcms.testcases import urls as testcases_urls
[Wed May 05 10:30:03.404321 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/tcms/testcases/urls/__init__.py", line 3, in <module>
[Wed May 05 10:30:03.404327 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     from . import case_urls, cases_urls
[Wed May 05 10:30:03.404335 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/tcms/testcases/urls/case_urls.py", line 5, in <module>
[Wed May 05 10:30:03.404341 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     from .. import views
[Wed May 05 10:30:03.404349 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/tcms/testcases/views.py", line 15, in <module>
[Wed May 05 10:30:03.404356 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     from tcms.testcases.forms import (
[Wed May 05 10:30:03.404365 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/tcms/testcases/forms.py", line 19, in <module>
[Wed May 05 10:30:03.404372 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     class TestCaseForm(forms.ModelForm):
[Wed May 05 10:30:03.404380 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/tcms/testcases/forms.py", line 31, in TestCaseForm
[Wed May 05 10:30:03.404386 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     queryset=Priority.objects.filter(is_active=True),
[Wed May 05 10:30:03.404396 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/django/db/models/manager.py", line 85, in manager_method
[Wed May 05 10:30:03.404402 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     return getattr(self.get_queryset(), name)(*args, **kwargs)
[Wed May 05 10:30:03.404411 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/django/db/models/query.py", line 941, in filter
[Wed May 05 10:30:03.404417 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     return self._filter_or_exclude(False, args, kwargs)
[Wed May 05 10:30:03.404426 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/django/db/models/query.py", line 961, in _filter_or_exclude
[Wed May 05 10:30:03.404433 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     clone._filter_or_exclude_inplace(negate, args, kwargs)
[Wed May 05 10:30:03.404442 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/django/db/models/query.py", line 968, in _filter_or_exclude_inplace
[Wed May 05 10:30:03.404449 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     self._query.add_q(Q(*args, **kwargs))
[Wed May 05 10:30:03.404458 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/django/db/models/sql/query.py", line 1391, in add_q
[Wed May 05 10:30:03.404464 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     clause, _ = self._add_q(q_object, self.used_aliases)
[Wed May 05 10:30:03.404473 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/django/db/models/sql/query.py", line 1415, in _add_q
[Wed May 05 10:30:03.404480 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     joinpromoter.add_votes(needed_inner)
[Wed May 05 10:30:03.404488 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/django/db/models/sql/query.py", line 2434, in add_votes
[Wed May 05 10:30:03.404494 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     self.votes.update(votes)
[Wed May 05 10:30:03.404504 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/collections/__init__.py", line 614, in update
[Wed May 05 10:30:03.404510 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     if isinstance(iterable, Mapping):
[Wed May 05 10:30:03.404519 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/abc.py", line 193, in __instancecheck__
[Wed May 05 10:30:03.404525 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     return cls.__subclasscheck__(subclass)
[Wed May 05 10:30:03.404534 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/abc.py", line 228, in __subclasscheck__
[Wed May 05 10:30:03.404539 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     if issubclass(subclass, scls):
[Wed May 05 10:30:03.404548 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/abc.py", line 228, in __subclasscheck__
[Wed May 05 10:30:03.404553 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     if issubclass(subclass, scls):
[Wed May 05 10:30:03.404562 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/usr/lib64/python3.6/typing.py", line 1154, in __subclasscheck__
[Wed May 05 10:30:03.404568 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     return super().__subclasscheck__(cls)
[Wed May 05 10:30:03.404576 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/abc.py", line 228, in __subclasscheck__
[Wed May 05 10:30:03.404583 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     if issubclass(subclass, scls):
[Wed May 05 10:30:03.404591 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/typing_extensions.py", line 800, in __subclasscheck__
[Wed May 05 10:30:03.404597 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     if issubclass(subclass, scls):
[Wed May 05 10:30:03.404607 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/typing_extensions.py", line 800, in __subclasscheck__
[Wed May 05 10:30:03.404612 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     if issubclass(subclass, scls):
[Wed May 05 10:30:03.404624 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/typing_extensions.py", line 800, in __subclasscheck__
[Wed May 05 10:30:03.404630 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     if issubclass(subclass, scls):
[Wed May 05 10:30:03.404639 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   [Previous line repeated 225 more times]
[Wed May 05 10:30:03.404649 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/site-packages/typing_extensions.py", line 784, in __subclasscheck__
[Wed May 05 10:30:03.404655 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     if sys.version_info[:3] >= (3, 5, 3) or sys.version_info[:3] < (3, 5, 0):
[Wed May 05 10:30:03.404704 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854] RecursionError: maximum recursion depth exceeded in comparison
172.19.0.1 - - [05/May/2021:10:30:03 +0000] "GET / HTTP/1.1" 500 527 "-" "curl/7.69.1"

See tests/runner.sh, tests/test_docker.sh and tests/test_http.sh in the git checkout for more information.

What bothers me is that I can only trigger this when trying to use HTTPS but not when using HTTP. Also when I run the container without the -e KIWI_DONT_ENFORCE_HTTPS=true option and access via HTTPS it seems to work so it is probably something transient which happens to trigger somewhat reliably.

Any help or hints ? Does this seem like a Django bug ?

It appears as if the actual recursion is occurring in the Python typing_extensions module. I see where a new release was released on May 1. Is it possible that there’s an issue with this new release?

As to how/why you’re getting this error, I’d want to know exactly what that subclass object is at the line below, and how it differs between the http and https versions when being run.

[Wed May 05 10:30:03.403690 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]   File "/venv/lib64/python3.6/abc.py", line 193, in __instancecheck__
[Wed May 05 10:30:03.403695 2021] [wsgi:error] [pid 11:tid 140162247923456] [remote 172.19.0.1:49854]     return cls.__subclasscheck__(subclass)

I’d also be tempted to try this with a different version of that module - either an older release of that module if you’re on that newest version, or the newer release if you’re still on an older release. Then I’d try it without that module at all. I might also try it with a newer version of Python.

Thanks for your tip. Indeed looking back at my CI jobs they started failing on May 4th and before we switched to Django 3.2. Reverting the Django version and even re-running one of our older pipelines failed with the same error.

I will dig more into the typing_extensions module and try to find some answers. Will post my findings here later.

I’ve tried with Python 3.8 and it worked. The error is no more. Since 3.8 was on our list to upgrade anyway I’m going with it. Thanks for your help!

1 Like