Skip to content

TypeError when confirming some subscriptions

it looks like the KeyError exceptions are mostly gone, but we're still seeing TypeError exceptions, and i think that's at least one of them:

2024-09-13T13:56:17.847153000Z [ERROR: django.request.log_response] Internal Server Error: /confirm-subscription
2024-09-13T13:56:17.847650000Z Traceback (most recent call last):
2024-09-13T13:56:17.847719000Z   File "/home/tordonate/venv/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
2024-09-13T13:56:17.847777000Z     response = get_response(request)
2024-09-13T13:56:17.847842000Z                ^^^^^^^^^^^^^^^^^^^^^
2024-09-13T13:56:17.847902000Z   File "/home/tordonate/venv/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
2024-09-13T13:56:17.847973000Z     response = wrapped_callback(request, *callback_args, **callback_kwargs)
2024-09-13T13:56:17.848049000Z                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-09-13T13:56:17.848126000Z   File "/home/tordonate/venv/lib/python3.11/site-packages/asgiref/sync.py", line 254, in __call__
2024-09-13T13:56:17.848208000Z     return call_result.result()
2024-09-13T13:56:17.848296000Z            ^^^^^^^^^^^^^^^^^^^^
2024-09-13T13:56:17.848360000Z   File "/usr/lib/python3.11/concurrent/futures/_base.py", line 449, in result
2024-09-13T13:56:17.848423000Z     return self.__get_result()
2024-09-13T13:56:17.848483000Z            ^^^^^^^^^^^^^^^^^^^
2024-09-13T13:56:17.848542000Z   File "/usr/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
2024-09-13T13:56:17.848603000Z     raise self._exception
2024-09-13T13:56:17.848679000Z   File "/home/tordonate/venv/lib/python3.11/site-packages/asgiref/sync.py", line 331, in main_wrap
2024-09-13T13:56:17.848734000Z     result = await self.awaitable(*args, **kwargs)
2024-09-13T13:56:17.848787000Z              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-09-13T13:56:17.848842000Z   File "/home/tordonate/venv/lib/python3.11/site-packages/dependency_injector/wiring.py", line 994, in _patched
2024-09-13T13:56:17.848900000Z     return await _async_inject(
2024-09-13T13:56:17.848955000Z            ^^^^^^^^^^^^^^^^^^^^
2024-09-13T13:56:17.849006000Z   File "src/dependency_injector/_cwiring.pyx", line 66, in _async_inject
2024-09-13T13:56:17.849058000Z   File "/home/tordonate/app/tordonate/civicrm/views.py", line 64, in confirm_subscription
2024-09-13T13:56:17.849118000Z     return await civi.confirm_subscription(request)
2024-09-13T13:56:17.849172000Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-09-13T13:56:17.849228000Z   File "/home/tordonate/app/tordonate/civicrm/repository.py", line 347, in confirm_subscription
2024-09-13T13:56:17.849293000Z     args = json.loads(
2024-09-13T13:56:17.849348000Z            ^^^^^^^^^^^
2024-09-13T13:56:17.849423000Z   File "/usr/lib/python3.11/json/__init__.py", line 339, in loads
2024-09-13T13:56:17.849478000Z     raise TypeError(f'the JSON object must be str, bytes or bytearray, '
2024-09-13T13:56:17.849530000Z TypeError: the JSON object must be str, bytes or bytearray, not NoneType
2024-09-13T13:56:17.849589000Z 0.0.0.0 - "GET /confirm-subscription?token=REDACTED HTTP/1.1" 500 145 658

We also get those, still:

2024-09-13T14:07:31.582668000Z Traceback (most recent call last):
2024-09-13T14:07:31.582710000Z   File "/home/tordonate/venv/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
2024-09-13T14:07:31.582747000Z     response = get_response(request)
2024-09-13T14:07:31.582782000Z                ^^^^^^^^^^^^^^^^^^^^^
2024-09-13T14:07:31.582815000Z   File "/home/tordonate/venv/lib/python3.11/site-packages/django/utils/deprecation.py", line 133, in __call__
2024-09-13T14:07:31.582849000Z     response = self.process_request(request)
2024-09-13T14:07:31.582882000Z                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-09-13T14:07:31.582915000Z   File "/home/tordonate/venv/lib/python3.11/site-packages/django/middleware/common.py", line 48, in process_request
2024-09-13T14:07:31.582947000Z     host = request.get_host()
2024-09-13T14:07:31.582980000Z            ^^^^^^^^^^^^^^^^^^
2024-09-13T14:07:31.583013000Z   File "/home/tordonate/venv/lib/python3.11/site-packages/django/http/request.py", line 150, in get_host
2024-09-13T14:07:31.583047000Z     raise DisallowedHost(msg)
2024-09-13T14:07:31.583083000Z django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: '49.12.57.139'. You may need to add '49.12.57.139' to ALLOWED_HOSTS.

... but that's more something TPA should fix by adding a proper redirect.

i'll also note that those exceptions fired but didn't raise an alarm, which is a bit of a problem that should be fixed, noted in #75 (closed).